Quantcast
Channel: GDS Web Design
Viewing all articles
Browse latest Browse all 59

Redirect non-admin users from wp-admin.

$
0
0

This simple function will redirect any logged in users (apart from admins) back to the homepage if they try to access the wp-admin folder directly. Add the following code your theme’s functions.php file.

add_action('admin_menu', 'redirect_dashboard');
function redirect_dashboard(){
    if( !current_user_can('level_10') ){
        if( preg_match('#wp-admin/?(index.php)?$#', $_SERVER['REQUEST_URI']) && ('index.php' != $menu[$page][2]) ) wp_redirect(get_bloginfo('url'));
    }
}

 


Viewing all articles
Browse latest Browse all 59

Trending Articles