Here at MembershipWorks, we automatically deploy a WordPress server whenever a user signs up for our service. The server is launched from an AMI image using Amazon EC2. We want the WordPress install to automatically activate our plugins. Instead of getting into MySQL, I figured the easiest way to deal with this is to add some actions to the install process.
The WordPress installation runs from wp-admin/install.php. What we are looking for is for certain actions to be triggered once the install is successful, so a good place to insert our code is right above this:
<h1><?php _e( 'Success!' ); ?></h1>
We see a code block that starts with:
if ( $error === false ) {
$wpdb->show_errors();
$result = wp_install($weblog_title, $user_name, $admin_email, $public, '', $admin_password);
extract( $result, EXTR_SKIP );
I chose to insert our actions after the last extract statement. To activate the plugins, I added:
require_once( dirname( dirname( __FILE__ ) ) . '/wp-admin/includes/plugin.php' );
activate_plugin( dirname( dirname( __FILE__ ) ) . '/wp-content/plugins/memberfindme/memberfindme.php' );
activate_plugin( dirname( dirname( __FILE__ ) ) . '/wp-content/plugins/wp101/wp101.php' );
That’s it! Happy modding!
Comments are closed.