• Home
  • Features
    • Membership Software
    • Member Directory
    • Event Calendar & Registration
    • Member Billing & Online Payments
    • Donations, Shopping Carts & Forms
    • Job Board
    • Announcement Board
    • Classified Ads
    • Members Only Website
    • Website Integration
      • WordPress
      • Squarespace
      • Weebly
      • Without Code
      • Duda
      • Wix
      • HTML5
    • Integrations
    • International
  • Sign Up
    • Pricing & Sign Up
  • Customers
    • Customer Sign In
    • Getting Started
      • MembershipWorks Hosted Website
      • WordPress Plugin
      • Squarespace
      • Weebly
      • Without Code
      • Wix
      • HTML5
    • Customer Websites
  • Developers
    • Find a Developer
    • Create a Developer Listing
    • Manage Developer Listing
  • Demo
    • WordPress Demo
    • Squarespace Demo
    • Weebly Demo
    • Without Code Demo
    • Duda Demo
    • Wix Demo
    • Video Demo of Admin
    • Schedule a Personal Demo
  • About
    • Contact Us
    • Cancel/Suspend Account
    • Schedule a Personal Demo
    • Schedule a Personal Training Session
    • Our Blogs
      • Guides
      • Best Practices
      • Secret Confessions of an ED
      • WordPress with the Light On
    • New Features
    • Careers
    • System Status
Schedule Demo

Discover our membership software with a one-on-one personalized demo:

Schedule a Demo
CMS Integrations

Integrate with WordPress, SquareSpace, Weebly and more.

Learn More!
MembershipWorkslogo

Automatically Activating a WordPress Plugin on Install

Posted on Feb 28, 2013 by Aikmeng KuahOct 3, 2019

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!

GoToOlder PostNewer PostAll PostsWordPress with the Light On

About Aikmeng Kuah

I'm co-founder and CTO of MembershipWorks. I've been writing code since the Apple II, in a variety of languages including x86 assembly, 68000 assembly, Pascal, Prolog, dBase, C, LISP, SQL, PHP and Javascript. I work on the full stack, from the web site design, front-end web app, back-end servers, database and API. I am a graduate of Carnegie Mellon University (BS) and University of Texas at Austin (PhD).View all posts by Aikmeng Kuah

Comments are closed.

  • Home
  • Features
  • Sign Up
  • Customer Sign-In
  • Terms of Service / Privacy
  • Developers
  • Contact