I am a WordPress themes developer. I saw some themes which ask the developer to install mandatory plugins while installing WordPress. I need to do the same for my WordPress theme. Please guide me how it is done. Thanks.

EDIT: Recent comment made me realize I hadn't made myself clear before. This is the functionality I am looking to add on my theme: enter image description here


1 Answer 1


You can use this script to achieve your answers of course you have to modify the css part and few here and there. :)

I am removing message if user clicks on Hide Notice link (or close button after css) if you don't want this functionality then remove the current_user click detection part also you have to add js to remove the message if user clicks on Hide Notice.

Also I am using class_exist to check, whether plugin is installed or not (hack), you can use is_plugin_active to detect.

I hope you get the idea.

Happy coding

if ( ! class_exists('fakerpress/fakerpress.php') && current_user_can( 'manage_options' ) )  {
    add_action('admin_notices', 'plugin_required_admin_notice');
    function plugin_required_admin_notice() {
        global $current_user ;
        $user_id = $current_user->ID;

        if ( ! get_user_meta($user_id, 'plugin_required_ignore_notice') ) {
             echo '<div class="updated"><p>';
             printf(__('This theme recommends the following plugins: <a href="%1$s">FakerPress</a> | <a href="%1$s">Hide Notice</a>'), '?plugin_required_nag_ignore=0');
             echo "</p></div>";

     add_action('admin_init', 'plugin_required_nag_ignore');
     function plugin_required_nag_ignore() {
         global $current_user;
         $user_id = $current_user->ID;

         if ( isset($_GET['plugin_required_nag_ignore']) && '0' == $_GET['plugin_required_nag_ignore'] ) {
             add_user_meta($user_id, 'plugin_required_ignore_notice', 'true', true);

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.