Tag Archives: admin

Disable wordpress admin for non administer users

/* Disable wordpress admin for non administer users*/

add_action( 'init', 'blockusers_init' );
function blockusers_init() {
    if ( is_admin() && ! current_user_can( 'administrator' ) &&
       ! ( defined( 'DOING_AJAX' ) && DOING_AJAX ) ) {
        wp_redirect( home_url() );
        exit;
    }
}

Add admin menu and submenu page


add_action('admin_menu', 'my_menu_pages');
function my_menu_pages(){
add_menu_page('None Members', 'None Members', 'manage_options', 'none-member', 'my_menu_output' );
add_submenu_page('none-member', 'Send bulk email', 'Send bulk email', 'manage_options', 'none-member' );
add_submenu_page('none-member', 'Members list', 'Members list', 'manage_options', 'my-menu2', 'memberslist' );
}
function my_menu_output(){
echo "<h2>Send Bulk Email</h2>";
}
function memberslist(){
echo "<h2>All Non members User</h2>";
}

Refrence:

http://wordpress.stackexchange.com/questions/66498/add-menu-page-with-different-name-for-first-submenu-item

%d bloggers like this: