Archive by Author
Activate WordPress Plugins Automatically via a Function

Activate WordPress Plugins Automatically via a Function

You have probably seen it before, you install a theme or plugin and a message displayed if you want to activate some related plugins as well.

In many cases, this could be a plugin that is necessary for the theme / plugin process or, in other cases, you just want to market another plugin that you developed or that you have a joint venture agreement with.

This simple tutorial will guide you on how to activate a plugin that is already installed, it will not show you how to install a plugin that is not already installed (we will cover it in a future tutorial).

The idea behind this process is simple, WordPress stores all the active plugins’ list in the options table.

A special field is assigned to that list under the name activate_plugins .

So in order to activate any plugin that is already installed we just need to change this field value.

Before we start writing the simple code, we need to find the plugin file name as we are going to use the activation process.

A simple way to find the plugin’s file name is by using the code below. These few lines will add the plugin’s file name into the plugins page list, so you can use the activation code later (a plugin version of this code is attached to this tutorial, you can download it and activate it on your website):

/* Getting plugin file names */

add_filter( 'plugin_row_meta', 'wpinsiders_get_plugin_string', 10, 4 );

function wpinsiders_get_plugin_string( $plugin_meta, $plugin_file, $plugin_data, $status ) {
	/* echo plugin file string */
	echo '<code>' . $plugin_file . '</code><br>';
	return $plugin_meta;
}


Now that we know the plugin's name, we can use the following code inside our plugin or theme in order to activate the plugin/s:

/* example on admin init, control about register_activation_hook()  */

add_action( 'admin_init', 'wpinsiders_activate_plugins' );
// the exmple function
function wpinsiders_activate_plugins() {
	
	if ( ! current_user_can('activate_plugins') )
		wp_die(__('You do not have sufficient permissions to activate plugins for this site.'));
	$plugins = FALSE;
	$plugins = get_option('active_plugins'); // get active plugins
	
	if ( $plugins ) {
		// plugins to active
		$plugins_to_activate = array(
			'hello.php', // Hello Dolly
			'adminimize/adminimize.php', // Adminimize
			'akismet/akismet.php' // Akismet
		);
		
		foreach ( $plugins_to_activate as $plugin ) {
			if ( ! in_array( $plugin, $plugins ) ) {
				array_push( $plugins, $plugin );
				update_option( 'active_plugins', $plugins );
			}
		}
		
	} // end if $plugins

}

As you can see in the above code, you can activate more than one plugin at once just by filling-in the right information inside the $plugin_to_activates  array.

Important Notice:

Important aspect that you should know about this process is: When WordPress activates a plugin on the back-end using the activate command in the plugins’ page, it is activating it inside a “sandbox”. If the plugin is broken, your website will not be broken and you will get a message regarding the plugin’s error on WordPress admin back-end.  However, when activating a plugin using a code, no sandbox is created and the plugin is activated in the live environment, so if the plugin that is activated has an error, it will break the website as well.

Examples for usage:

  • The plugin needs some other plugins activated in order to work properly.
  • You are creating a testing environment and you need to activate / deactivate several plugins at one.
  • You want to make sure a plugin is active (for any reason that you can think of).

If you like this tutorial share using the social sharing buttons, if you want to add new information feel free to write in the comments section below.

 

Wishlist Member Tips Series

Wishlist Member Tips Series

If you are a Wishlist Member user then our special tips series is just what you need to help your empower your membership site.

In this page you will find the complete list of tips we publish in the Wishlist Member Tips Series.

Register for free and get immediate access to all the previous and upcoming tips!

Access the complete list of tips

Premium Plugins & Guides for Wishlist Member at HappyPlugins.com

Premium Plugins & Guides for Wishlist Member at HappyPlugins

HappyPlugins is the largest online store for plugins and guides for Wishlist Member, here you will find plugins that will help empower your membership site, including plugins that will: automate your registration process, drip / archive content, integrate with popular platforms such as WooCommerce & bbPress and a lot more…  Check out all the plugins at HappyPlugins.com

Does Wishlist Member WooCommerce Plus Handle Multi-Currency Payments?

Is Wishlist Member plugin slowing my website?

Question:

“I’m running my membership site on Wishlist Member plugin and I’m worried that it might slow down my site. Is it possible that the Wishlist plugin is causing this and what can I do to make it run faster?”

Read more…

Wishlist Member Plugins Wizard

Wishlist Member Plugins Wizard

Welcome to the complete Wishlist Member Plugins Wizard!

The Wizard contains 65 Wishlist dedicated plugins to empower your membership site.

The relevant information will open according to the answers you click on.

It may take a couple of seconds for the wizard to be displayed. If not, please refresh the page or open the page in Internet Explorer, for some reason it works best there…

If this link doesn’t work, please go to the Wishlist Member Plugins Complete Repository to view all plugins

Follow the Wizard Below:

Wishlist Member Plugins Wizard is Powered by Wishlist Selector

Check Our Wishlist Member Tips Series

These are only some of the tips you will find (must be logged-in):

Get all the tips in this link

Not a Member Yet?

Register for free using the form to your right.

 

 

 

 

 

300-facebook-fans

300 Facebook Fans

We have reached 300 fans on our new Facebook page.

If you think any of your friends would enjoy the information on this website than share it with them.

Help your friends and give them the most recent information on all Wishlist Member plugins and much more.

And one more thing… If you haven’t liked out Facebook page yet do it now, many surprises are coming soon to all our Facebook fans.

Wishlist insider - Monthly Bonus Plugin

Wishlist Comment Headings – Wishlist Insider Bonus Plugin (January 2012)

It’s this time in the month… The Wishlist Insider Bonus plugin is going to be released next Thuesday.

This month’s plugin is Wishlist Comment Headings.

Like in every Wishlist Insider bonus plugin release, the Wishlist team does not reveal any information on the plugin, but from its name, you can probably guess what it will do. Read more…

Marketing Nuggets Series

Marketing Nuggets Post #003

This week on Marketing Nuggets 3 articles that will inspire you and give a new point of view on marketing.

We always say that in order to be a good marketer you just need to look at things from a unique point of view.

So without long intro these are our top 3 nuggets for this week:

  • Marketing Nugget #1–  10 Documentaries That Will Teach Any Entrepreneur How To Think Differently
  • Marketing Nugget #2– Big Think Interview With Dan Ariely.  A conversation with the James B. Duke Professor of Psychology and Behavioral Economics at Duke University.
  • Marketing Nugget #3– How to Set Goals and Motivate Yourself to Actually Achieve Them
If you are a registered member, you can log-in to read your nuggets.

If you are still not a member, you can register for FREE on the form to your right.

Remember:

As a registered member you will be able to see the current Marketing Nugget post and future ones.

If you register after the next Marketing Nugget post will be released, you will not able to access any past Nuggets.

Read more…

Wishlist insider - Monthly Bonus Plugin

Wishlist Welcome – Wishlist Insider Bonus Plugin (November 2012)

It’s this time in the month… The Wishlist Insider Bonus plugin is going to be released next Thuesday.

This month’s plugin is Wishlist Welcome.

Like in every Wishlist Insider bonus plugin release, the Wishlist team does not reveal any information on the plugin, but from its name, you can probably guess what it will do. Read more…

present

Wishlist Member is Celebrating 4 Years and You Get the Presents

Wishlist Member is in the air for 4 years, and we have absolutely no doubt it will stick around for many years to come.

There’s no doubt that Wishlist is one of the best plugins for building membership sites, and it only gets better and better in time.

Today we just wanted to let you know that the Wishlist guys are giving away some awesome presents for their members, so if you still hadn’t purchased the plugin, you should do it before the end of October.

Wishlist Member’s 4th Anniverary for New Customers Who Joins Till October 31, 2012

Read more…

Wishlist Smart Shortcodest - Improve your Membership Site
This Website is Using Wishlist Memers Count to Increase Members Registration
Wishlist Registration Widget - Increase Members Registration
We are the Biggest 3rd Party Company that Sells Plugins for the WishList Member Platform. Read More About Us
/* */