Unable to access theme activation page – permission issue

Question

I am constantly getting the “Sorry, you are not allowed to access this page” when I click the submit_button from the theme activation.

But if I go to the wp-admin page directly in the address bar I can see the dashboard.

This is causing issues as part of the activation is to create pages, and user creations, etc.

I am running this from a multisite, and via a must-use plugin (which I haven’t found any issues about doing). This is all for internal site – and maintained purely by me.

The only issue I have found is that $pagenow doesn’t work on multisites (TRAC link).

I wonder if anyone can find any issues with what I have here:

// is the theme reset
function mb_is_reset() {
    $mb_theme_activated = ( get_option( 'mb_theme_activated' ) === 'true' ? true : null );
    $mb_theme_is_reset  = ( get_option( 'mb_theme_is_reset'  ) === 'true' ? true : null );

    // return NULL if none are set, otherwise show status
    return ( is_null($mb_theme_activated) && is_null($mb_theme_is_reset) ? null :
           ( !$mb_theme_activated && $mb_theme_is_reset ? true : false ) );
}

// admin theme activation redirects
if( is_admin() ) {
    // action: reset
    if( (isset( $_GET['mb_theme_action'] )  && $_GET['mb_theme_action'] === 'reset') ||
        (isset( $_GET['activated'] )        && $_GET['activated']       === 'true')
    ) {
        // clean the options; redirect to the activation
        mb_theme_deactivation();
        echo '<script>';
            echo 'window.location.replace("' . admin_url('themes.php?page=mb_theme_options') . '");';
        echo '</script>';
    }

    // action: success
    // if( isset($_GET['page']) && $_GET['page'] === 'mb_theme_options' ) {
    if(
        isset($_GET['page'])                && $_GET['page']                === 'mb_theme_options' &&
        isset($_GET['settings-updated'])    && $_GET['settings-updated']    === 'true'
    ) {

        flush_rewrite_rules( false );

        // for the permalinks; set the forced setup; redirect to the setup page -- 30 seconds delay
        update_option( 'mb_theme_setup',            '1' );      // send to page setup
        update_option( 'mb_theme_activated',        'true' );   // theme is activated
        update_option( 'mb_theme_is_reset',         'false' );  // theme is not reset

        echo '<script>';
            echo 'window.location.replace("' . home_url('/admin/login/') . '");';
        echo '</script>';

    }
}



// add the theme reset button
function mb_theme_admin_bar_reset() {
    global $wp_admin_bar;

    // main args
    $args_00 =  array(
                    'id'        => 'mb_theme_action',
                    'group'     => false,
                    'meta'      => array( 'html' => '<style>#wp-admin-bar-mb_theme_action a{background:#B33771 !important;font-weight:bold;}</style>' )
                );

    // if not reset, and not on the activation page
    if( mb_is_reset() === false && !( isset($_GET['page']) && $_GET['page'] === 'mb_theme_options' ) ) {
        $args_01 = array(
            'title'     => 'Reset',
            'href'      => admin_url('?mb_theme_action=reset')
        );
    } else {
        $args_01 = array(
            'title'     => 'Activate',
            'href'      => admin_url('themes.php?page=mb_theme_options')
        );
    }

    // add the bar item
    $wp_admin_bar->add_menu( array_merge( $args_00, $args_01 ) );
}

// admin notice
function mb_theme_admin_notices() {
    if( mb_is_reset() === true && !( isset($_GET['page']) && $_GET['page'] === 'mb_theme_options' ) ) {
        echo '<div class="notice notice-info">';
            echo '<p>You have not activated the <strong>mbWebOS theme</strong>. ';
            echo '<a href="themes.php?page=mb_theme_options">Activate it now</a></p>';
        echo '</div>';
    }
}

// when switching theme
function mb_theme_deactivation() {

    // delete all options from activation
    delete_option( 'mb_setting_authentication'      );
    delete_option( 'mb_setting_domain'              );
    delete_option( 'mb_setting_heartbeat'           );
    delete_option( 'mb_setting_lockout'             );
    delete_option( 'mb_setting_password'            );
    delete_option( 'mb_setting_refresh'             );
    delete_option( 'mb_setting_taxonomy'            );
    delete_option( 'mb_setting_taxonomy_label'      );
    delete_option( 'mb_setting_testing'             );

    if( isset($_GET['mb_theme_action']) && $_GET['mb_theme_action'] === 'reset' ) {
        update_option( 'mb_theme_activated',    'false' );
        update_option( 'mb_theme_is_reset',     'true'  );

        $mb_pages_ids = get_all_page_ids();
        foreach( $mb_pages_ids as $mb_page ) {
            wp_delete_post( $mb_page, true );
        }
    } else {
        delete_option( 'mb_theme_activated'         );
        delete_option( 'mb_theme_is_reset'          );
    }

    // delete the theme options
    delete_option( 'mb_theme_options'               );
}

// register the options
function mb_theme_options_init() {
    register_setting( 'mb_activation_options', 'mb_theme_options' );
}

// active the capability
function mb_theme_options_page_capability( $capability ) {
    return 'edit_theme_options';
}

// generate the theme activation page
function mb_theme_options_add_page() {
    $mb_activation_options = mb_get_theme_options();

    // if the option is not set send to the options page
    if( !$mb_activation_options ) {
        $theme_page = add_theme_page(
                        'mbWebOS Theme activation',     // theme: page title
                        'mbWebOS activation',           // theme: menu title
                        'edit_theme_options',           // theme: capability
                        'mb_theme_options',             // theme: menu slug
                        'mb_theme_options_render_page'  // theme: callback function
                      );
    }
}

// get the options of the activation
function mb_get_theme_options() {
    return get_option('mb_theme_options');
}

// generate the theme render page
function mb_theme_options_render_page() { ?>
    <div class="mbwrap" style="width:60vw;padding: 2em;">

        <div>
            <h1 style="margin-bottom: 0.1em;"><strong>mbWebOS</strong> Theme Activation</h1>
            <span style="font-size: 1em;">by Mark Battistella</span>
        </div>

        <?php settings_errors(); ?>

        <form method="post" action="options.php">

            <?php settings_fields('mb_activation_options'); ?>

            <h3>Welcome to the <u><?= wp_get_theme(); ?></u> activation page!</h3>

            <p style="font-size:120%;">
                In order to help create new themes, and generate ease I have
                created it to generate the default pages, users, capabilities,
                among other things in the background so I don't have to do it
                every single time.
            </p>

            <p style="font-size:120%;">
                Once activation is completed you will be redirected to the
                <strong>initial setup</strong> page where you can select some
                extra options for this site. This includes whether there is a
                need for login authentication, use of the server side event
                heartbeat, theme colour, etc.
            </p>

            <style>.button-hero { width: 100%; }</style>

            <input value="true" hidden="hidden" name="mb_theme_options[set_options]">
            <input value="true" hidden="hidden" name="mb_theme_options[set_permalinks]">
            <input value="true" hidden="hidden" name="mb_theme_options[set_uploads]">
            <input value="true" hidden="hidden" name="mb_theme_options[set_permissions]">
            <input value="true" hidden="hidden" name="mb_theme_options[set_categories]">
            <input value="true" hidden="hidden" name="mb_theme_options[set_users]">
            <input value="true" hidden="hidden" name="mb_theme_options[set_pages]">

            <?php
                // style the button
                submit_button( 'Activate theme', 'primary button-hero' );
            ?>

        </form>
    </div>
<?php }

// begin the activation action
function mb_theme_activation_action() {

    // just some checks before we activate
    // stop executing activation if we're not supposed to
    // if the page is not coming from the intended location stop
    if( !($mb_theme_options = mb_get_theme_options()) ||
        strpos( wp_get_referer(), 'page=mb_theme_options' ) === false
    ) {
        return;
    }


    // activation: set_pages
    if( $mb_theme_options['set_pages'] === 'true' ) {
        $mb_theme_options['set_pages'] = false;

        // delete default post
        $default_wp_page = get_page_by_title( 'Sample Page', OBJECT, 'page' );
        $default_wp_post = get_page_by_title( 'Hello World!', OBJECT, 'post' );
            if( $default_wp_post != NULL ) { wp_delete_post( $default_wp_post->ID, true ); }
            if( $default_wp_page != NULL ) { wp_delete_post( $default_wp_page->ID, true ); }

        // create the parent pages
        $mb_theme_page00 = array( 'post_content' => '', 'post_status' => 'publish', 'post_type' => 'page' );

        $mb_theme_page01 = array( 'post_title' => 'Home',   'post_name' => 'home'   );
        $mb_theme_page02 = array( 'post_title' => 'Admin',  'post_name' => 'admin'  );
            $mb_theme_page01_id = wp_insert_post( array_merge( $mb_theme_page00, $mb_theme_page01 ) );
            $mb_theme_page02_id = wp_insert_post( array_merge( $mb_theme_page00, $mb_theme_page02 ) );

        $mb_theme_page03 = array( 'post_title' => 'Login',          'post_name' => 'login',     'post_parent' => $mb_theme_page02_id );
        $mb_theme_page04 = array( 'post_title' => 'Logout',         'post_name' => 'logout',    'post_parent' => $mb_theme_page02_id );
        $mb_theme_page05 = array( 'post_title' => 'Password',       'post_name' => 'pw',        'post_parent' => $mb_theme_page02_id );
        $mb_theme_page06 = array( 'post_title' => 'Initial Setup',  'post_name' => 'setup',     'post_parent' => $mb_theme_page02_id );
        $mb_theme_page07 = array( 'post_title' => 'Privacy',        'post_name' => 'privacy',   'post_parent' => $mb_theme_page01_id );

            $mb_theme_page03_id = wp_insert_post( array_merge( $mb_theme_page00, $mb_theme_page03 ) );
            $mb_theme_page04_id = wp_insert_post( array_merge( $mb_theme_page00, $mb_theme_page04 ) );
            $mb_theme_page05_id = wp_insert_post( array_merge( $mb_theme_page00, $mb_theme_page05 ) );
            $mb_theme_page06_id = wp_insert_post( array_merge( $mb_theme_page00, $mb_theme_page06 ) );
            $mb_theme_page07_id = wp_insert_post( array_merge( $mb_theme_page00, $mb_theme_page07 ) );

        // set `posts` to show on front
        update_option( 'show_on_front',  'page' );
        update_option( 'page_on_front',  $mb_theme_page01_id );

        update_option( 'page_for_privacy_policy',       $mb_theme_page07_id );
        update_option( 'wp_page_for_privacy_policy',    $mb_theme_page07_id );

        // set `Home` to be -1 page order
        $mb_theme_page_01_menu_order = array( 'ID' => $mb_theme_page01_id, 'menu_order' => -1);
        wp_update_post( $mb_theme_page_01_menu_order );
    }

    // activation: set_categories
    if( $mb_theme_options['set_categories'] === 'true' ) {
        $mb_theme_options['set_categories'] = false;

        // create the category lists
        $tax01_id = wp_insert_category( array(
                                        'category_nicename' => 'null',
                                        'category_parent'   => '',
                                        'cat_ID'            => 1,
                                        'cat_name'          => 'null'
                                    ) );
    }

    // activation: set_options
    if( $mb_theme_options['set_options'] === 'true' ) {
        $mb_theme_options['set_options'] = false;

        update_option( 'blog_public',                   '0' );
        update_option( 'close_comments_days_old',       '0' );
        update_option( 'close_comments_for_old_posts',  '0' );
        update_option( 'close_comments_for_old_posts',  '1' );
        update_option( 'comments_notify',               '0' );
        update_option( 'comments_per_page',             '1' );
        update_option( 'comment_max_links',             '0' );
        update_option( 'comment_registration',          '0' );
        update_option( 'comment_whitelist',             '0' );
        update_option( 'default_comment_status',        '0' );
        update_option( 'default_pingback_flag',         '0' );
        update_option( 'default_ping_status',           'closed'        );
        update_option( 'moderation_notify',             '0' );
        update_option( 'page_comments',                 '0' );
        update_option( 'posts_per_page',                '1' );
        update_option( 'posts_per_rss',                 '1' );
        update_option( 'require_name_email',            '0' );
        update_option( 'show_avatars',                  '0' );
        update_option( 'show_comments_cookies_opt_in',  '0' );
        update_option( 'thread_comments',               '0' );
        update_option( 'thread_comments',               '0' );
        update_option( 'thread_comments_depth',         '0' );
        update_option( 'users_can_register',            '0' );
        update_option( 'use_smilies',                   '0' );
        update_option( 'use_trackback',                 '0' );

        update_option( 'default_role',                  'internal_user'         );
        update_option( 'date_format',                   'F jS, Y'               );
        update_option( 'timezone_string',               'Australia/Melbourne'   );
        update_option( 'blogdescription',               'by Mark Battistella'   );

        // custom options
        $theme_random = str_pad( rand(0, 18), 2, 0, STR_PAD_LEFT );
        update_option( 'mb_setting_theme',              'theme-' . $theme_random ); // colour #2980b9
        update_option( 'mb_setting_testing',            'false'         ); // testing mode
        update_option( 'mb_setting_lockout',            'false'         ); // not locked

        update_option( 'mb_setting_authentication',     'true'          ); // need a login by default
        update_option( 'mb_setting_heartbeat',          'false'         ); // do not use heartbeat
        update_option( 'mb_setting_refresh',            '300'           ); // set the refresh timer
        update_option( 'mb_setting_taxonomy',           'false'         ); // do not create a taxonomy
        update_option( 'mb_setting_taxonomy_label',     ''              ); // do not create a taxonomy

        update_option( 'mb_setting_domain',             'domain.ltd'    );
        update_option( 'mb_setting_password',           'summer123'     );
    }

    // activation: set_permalinks
    if( $mb_theme_options['set_permalinks'] === 'true' ) {
        $mb_theme_options['set_permalinks'] = false;

        if( get_option('permalink_structure') !== '/%postname%/' ) {
            global $wp_rewrite;
            $wp_rewrite->set_permalink_structure( '/%postname%/' );
            $wp_rewrite->set_category_base( 's' );
            $wp_rewrite->set_tag_base( 't' );
            flush_rewrite_rules();
        }
    }

    // activation: set_uploads
    if( $mb_theme_options['set_uploads'] === 'true' ) {
        $mb_theme_options['set_uploads'] = false;

        update_option( 'uploads_use_yearmonth_folders', 0 );

        if( is_multisite() ) {
            update_option( 'upload_path', ''        );
        } else {
            update_option( 'upload_path', 'media'   );
        }

        // make the default CSS, IMG, JS items
        if( function_exists('mb_default_assets') ) {
            mb_default_assets();
        }
    }

    // activation: set_permissions
    if( $mb_theme_options['set_permissions'] === 'true' ) {
        $mb_theme_options['set_permissions'] = false;

        // remove unwanted users
        if( get_role( 'subscriber'  ) ) { remove_role( 'subscriber' ); }
        if( get_role( 'contributor' ) ) { remove_role( 'contributor'); }
        if( get_role( 'author'      ) ) { remove_role( 'author'     ); }
        if( get_role( 'editor'      ) ) { remove_role( 'editor'     ); }

        // generate new permissions: site owner
        $mb_theme_admin_cap = array(
            'activate_plugins'          => true,
            'add_users'                 => true,
            'create'                    => true,
            'create_sites'              => true,
            'create_users'              => true,
            'customize'                 => true,
            'delete'                    => true,
            'delete_others_pages'       => true,
            'delete_others_posts'       => true,
            'delete_pages'              => true,
            'delete_plugins'            => true,
            'delete_posts'              => true,
            'delete_private_pages'      => true,
            'delete_private_posts'      => true,
            'delete_published_pages'    => true,
            'delete_published_posts'    => true,
            'delete_site'               => true,
            'delete_sites'              => true,
            'delete_themes'             => true,
            'delete_users'              => true,
            'edit'                      => true,
            'edit_dashboard'            => true,
            'edit_files'                => true,
            'edit_others_pages'         => true,
            'edit_others_posts'         => true,
            'edit_pages'                => true,
            'edit_plugins'              => true,
            'edit_posts'                => true,
            'edit_private_pages'        => true,
            'edit_private_posts'        => true,
            'edit_published_pages'      => true,
            'edit_published_posts'      => true,
            'edit_theme_options'        => true,
            'edit_themes'               => true,
            'edit_users'                => true,
            'export'                    => true,
            'import'                    => true,
            'install_plugins'           => true,
            'install_themes'            => true,
            'list_users'                => true,
            'manage_categories'         => true,
            'manage_links'              => true,
            'manage_network'            => true,
            'manage_network_options'    => true,
            'manage_network_plugins'    => true,
            'manage_network_themes'     => true,
            'manage_network_users'      => true,
            'manage_options'            => true,
            'manage_sites'              => true,
            'moderate_comments'         => true,
            'promote_users'             => true,
            'publish_pages'             => true,
            'publish_posts'             => true,
            'read_private_pages'        => true,
            'read_private_posts'        => true,
            'remove_users'              => true,
            'setup_network'             => true,
            'switch_themes'             => true,
            'update_core'               => true,
            'update_plugins'            => true,
            'update_themes'             => true,
            'upgrade_network'           => true,
            'upload_files'              => true,
            'read'                      => true
        );

        // generate new permissions: default
        $mb_theme_default_cap = array(
            'activate_plugins'          => false,
            'add_users'                 => false,
            'create'                    => false,
            'create_sites'              => false,
            'create_users'              => false,
            'customize'                 => false,
            'delete'                    => false,
            'delete_others_pages'       => false,
            'delete_others_posts'       => false,
            'delete_pages'              => false,
            'delete_plugins'            => false,
            'delete_posts'              => false,
            'delete_private_pages'      => false,
            'delete_private_posts'      => false,
            'delete_published_pages'    => false,
            'delete_published_posts'    => false,
            'delete_site'               => false,
            'delete_sites'              => false,
            'delete_themes'             => false,
            'delete_users'              => false,
            'edit'                      => false,
            'edit_dashboard'            => false,
            'edit_files'                => false,
            'edit_others_pages'         => false,
            'edit_others_posts'         => false,
            'edit_pages'                => false,
            'edit_plugins'              => false,
            'edit_posts'                => false,
            'edit_private_pages'        => false,
            'edit_private_posts'        => false,
            'edit_published_pages'      => false,
            'edit_published_posts'      => false,
            'edit_theme_options'        => false,
            'edit_themes'               => false,
            'edit_users'                => false,
            'export'                    => false,
            'import'                    => false,
            'install_plugins'           => false,
            'install_themes'            => false,
            'list_users'                => false,
            'manage_categories'         => false,
            'manage_links'              => false,
            'manage_network'            => false,
            'manage_network_options'    => false,
            'manage_network_plugins'    => false,
            'manage_network_themes'     => false,
            'manage_network_users'      => false,
            'manage_options'            => false,
            'manage_sites'              => false,
            'moderate_comments'         => false,
            'promote_users'             => false,
            'publish_pages'             => false,
            'publish_posts'             => false,
            'read_private_pages'        => false,
            'read_private_posts'        => false,
            'remove_users'              => false,
            'setup_network'             => false,
            'switch_themes'             => false,
            'update_core'               => false,
            'update_plugins'            => false,
            'update_themes'             => false,
            'upgrade_network'           => false,
            'upload_files'              => false,
            'read'                      => false
        );

        // generate new permissions: site_owner, site_manager, internal, external, client, viewer
        $mb_theme_owner_cap     = array(
                                        'site_owner'        => true,    // used to check
                                        'site_manager'      => true,    // used to check
                                        'internal_user'     => true,    // used to check
                                        'external_user'     => true,    // used to check
                                        'client_user'       => true,    // used to check
                                        'viewer_user'       => true     // used to check
                                );
        $mb_theme_manager_cap   = array(
                                        'site_owner'        => false,   // used to check
                                        'site_manager'      => true,    // used to check
                                        'internal_user'     => true,    // used to check
                                        'external_user'     => true,    // used to check
                                        'client_user'       => true,    // used to check
                                        'viewer_user'       => true     // used to check
                                );
        $mb_theme_internal_cap  = array(
                                        'site_owner'        => false,   // used to check
                                        'site_manager'      => false,   // used to check
                                        'internal_user'     => true,    // used to check
                                        'external_user'     => false,   // used to check
                                        'client_user'       => false,   // used to check
                                        'viewer_user'       => false    // used to check
                                );
        $mb_theme_external_cap  = array(
                                        'site_owner'        => false,   // used to check
                                        'site_manager'      => false,   // used to check
                                        'internal_user'     => false,   // used to check
                                        'external_user'     => true,    // used to check
                                        'client_user'       => false,   // used to check
                                        'viewer_user'       => false    // used to check
                                );
        $mb_theme_client_cap    = array(
                                        'site_owner'        => false,   // used to check
                                        'site_manager'      => false,   // used to check
                                        'internal_user'     => false,   // used to check
                                        'external_user'     => false,   // used to check
                                        'client_user'       => true,    // used to check
                                        'viewer_user'       => false    // used to check
                                );
        $mb_theme_viewer_cap    = array(
                                        'site_owner'        => false,   // used to check
                                        'site_manager'      => false,   // used to check
                                        'internal_user'     => false,   // used to check
                                        'external_user'     => false,   // used to check
                                        'client_user'       => false,   // used to check
                                        'viewer_user'       => true     // used to check
                                );

        // set the roles
        $mb_theme_site_owner    = add_role( 'site_owner',    'Site Owner',    array_merge( $mb_theme_admin_cap,   $mb_theme_owner_cap    ));
        $mb_theme_site_manager  = add_role( 'site_manager',  'Site Manager',  array_merge( $mb_theme_admin_cap,   $mb_theme_manager_cap  ));
        $mb_theme_internal_user = add_role( 'internal_user', 'Internal User', array_merge( $mb_theme_default_cap, $mb_theme_internal_cap ));
        $mb_theme_external_user = add_role( 'external_user', 'External User', array_merge( $mb_theme_default_cap, $mb_theme_external_cap ));
        $mb_theme_client_user   = add_role( 'client_user',   'Client User',   array_merge( $mb_theme_default_cap, $mb_theme_client_cap   ));
        $mb_theme_viewer_user   = add_role( 'viewer_user',   'Viewer User',   array_merge( $mb_theme_default_cap, $mb_theme_viewer_cap   ));

        // add superuser to site_owner
        $super_admin = get_user_by( 'id', get_current_user_id() );
        $super_admin->add_role('site_owner');
    }

    // activation: set_users
    if( $mb_theme_options['set_users'] === 'true' ) {
        $mb_theme_options['set_users'] = false;

        // check mb_admin is added to all blogs
        if( username_exists('mb_admin') && !is_user_member_of_blog( username_exists('mb_admin'), get_current_blog_id() ) ) {
            $mb_admin_user_id = username_exists('mb_admin');
            add_user_to_blog( get_current_blog_id(), $mb_admin_user_id, 'site_owner' );
            update_user_meta( $mb_admin_user_id, 'mb_resetpw',      0 ); // do not reset password
            update_user_meta( $mb_admin_user_id, 'mb_deactivated',  0 ); // is not deactivated user

        // otherwise create the user
        } else {
            $mb_admin_user = array(
                'user_pass'         => get_option('mb_setting_password'),
                'user_login'        => 'mb_admin',
                'user_email'        => null,
                'display_name'      => 'Site Administrator',
                'nickname'          => null,
                'first_name'        => null,
                'last_name'         => null,
                'user_registered'   => date( 'Y-m-d H:i:s', current_time( 'timestamp', 0 ) ),
                'role'              => 'site_owner',
                'rich_editing'      => false
            );

            // create the user
            $mb_admin_user_id = wp_insert_user( $mb_admin_user );

            // add the user to this site, deactivate them, and make them
            // force password change. manual sql entry into database to activate
            if( !is_wp_error($mb_admin_user_id) ) {
                add_user_to_blog( get_current_blog_id(), $mb_admin_user_id, 'site_owner' ); # do we need this?
                update_user_meta( $mb_admin_user_id, 'mb_resetpw',      '1' ); // do reset password
                update_user_meta( $mb_admin_user_id, 'mb_deactivated',  '1' ); // is deactivated user
            }
        }

        // create the unique viewer user to blog
        if( !username_exists('mb_viewer_' . get_current_blog_id()) ) {
            $mb_viewer_user = array(
                'user_pass'         => get_option('mb_setting_password'),
                'user_login'        => ( 'mb_viewer_' . get_current_blog_id() ),
                'user_email'        => null,
                'display_name'      => ( 'mbViewer for: ' . get_current_blog_id() ),
                'nickname'          => null,
                'first_name'        => null,
                'last_name'         => null,
                'user_registered'   => date( 'Y-m-d H:i:s', current_time( 'timestamp', 0 ) ),
                'role'              => 'viewer_user',
                'rich_editing'      => false
            );

            // create the user
            $mb_viewer_user_id = wp_insert_user( $mb_viewer_user );

            if( !is_wp_error($mb_viewer_user_id) ) {
                add_user_to_blog( get_current_blog_id(), $mb_viewer_user_id, 'viewer_user' ); # do we need this?
                update_user_meta( $mb_viewer_user_id, 'mb_resetpw',     '0' ); // do not reset password
                update_user_meta( $mb_viewer_user_id, 'mb_deactivated', '0' ); // is not deactivated user
            }
        }
    }

    // update the options from the theme activation
    update_option('mb_theme_options', $mb_theme_options);
}






// apply all the activations
add_action( 'wp_before_admin_bar_render',                   'mb_theme_admin_bar_reset',         999 );
add_action( 'admin_notices',                                'mb_theme_admin_notices'                );
add_action( 'switch_theme',                                 'mb_theme_deactivation'                 );
add_action( 'admin_init',                                   'mb_theme_options_init'                 );
add_filter( 'option_page_capability_mb_theme_options',      'mb_theme_options_page_capability'      );
add_action( 'admin_init',                                   'mb_theme_activation_action'            );
add_action( 'admin_menu',                                   'mb_theme_options_add_page',        50  );
0
, markb 2 years 2019-12-29T04:28:15-05:00 0 Answers 100 views 0

Leave an answer

Browse
Browse