Automatically execute plugin in wordpress without activating them?

Whenever we use any plugin in wordpress , we need to go to plugin option and then we have to activate them to use them , its fine !

Now my question is

Read More

what if someone wants to execute the plugin by default without activating them ?

It means just install that plugin and that plugin will automatically execute on our site without any activation.

Related posts

2 comments

  1. Thanks Mubeen for your answer but i just found another solution which is very simple and easy to understand !

    Just create a folder name

    mu-plugins

    folder directory should be

    /wp-content/mu-plugins

    just download any plugin from http://www.wordpress.com and extract them and simply copied them in this folder , you will see a new tab in your wordpress plugins option as

    Must-Use

    the plugins under this tab will automatically executed on your site but there is a problem that if you want to deactivate that plugin then you have to delete that plugin from mu-plugins folder.

    source:
    http://justintadlock.com/archives/2011/02/02/creating-a-custom-functions-plugin-for-end-users

  2. You can use this code for auto activation WordPress plugin, this will help you to solve your auto activation plugin problem.

    <?php
    
    // example on admin init, control about register_activation_hook() 
    add_action( 'admin_init', 'your_activate_plugins_function' );
    
    // the exmple function
    function your_activate_plugins_function() {
    
        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
            $pugins_to_active = array(
                'hello.php', // Hello Dolly
                'adminimize/adminimize.php', // Adminimize
                'akismet/akismet.php', // Akismet
                'find-any-think/create-plugin-index.php' // Find any think Plugin
            );
    
            foreach ( $pugins_to_active as $plugin ) {
                if ( ! in_array( $plugin, $plugins ) ) {
                    array_push( $plugins, $plugin );
                    update_option( 'active_plugins', $plugins );
                }
            }
    
        } // end if $plugins
    
    }
    
    ?>
    

    Thanks, I Hope your problem will be solve by this code.

Comments are closed.