-
A new registrant is best “gamer” role!But “contributor” and “editor” role should be allowed to log in to the dashboard.
If there is more than one contributor,Do I have to change everyone to “administrator” role?
#functions.php
/*hide admin bar for all users except admin*/
function skywarrior_admin_bar(){if (!current_user_can(‘administrator‘) && !is_admin()) {
show_admin_bar(false);
}
}
add_action( ‘after_setup_theme’ , ‘skywarrior_admin_bar’);/*restrict admi naccess for non admins*/
function skywarrior_restrict_admin() {
$user = new WP_User( get_current_user_id() );
if ( !current_user_can( ‘manage_options’ ) ) {
if($user->roles[0] !=’gamer‘){
wp_die( __(‘You are not allowed to access this part of the site’, ‘blackfyre’));
}elseif((strpos($_SERVER[‘REQUEST_URI’], “post_type=clan”) != true) && (strpos($_SERVER[‘REQUEST_URI’], “admin-ajax.php”) != true) && (strpos($_SERVER[‘REQUEST_URI’], “post.php”) == true && strpos($_SERVER[‘REQUEST_URI’], “image-editor”) == true) ) {
wp_die( __(‘You are not allowed to access this part of the site’, ‘blackfyre’));
}
}
}Is there a way to add other roles?
-
Please use the search before making a post. Your question maybe be already answered!
-
Do you need customization work? Are you having trouble installing Wordpress? Feeling lazy and want somebody else to do the hard work for you?
Join our discord!
Need hosting?
Follow us!