• I created a new role with edit-profile cap I used this function for hide administrator from users list

    function isa_pre_user_query($user_search) {
    	global $pagenow;
        if (!current_user_can('administrator')) {
    	global $wpdb;
    	$user = wp_get_current_user();
        $user_search->query_where =
            str_replace('WHERE 1=1',
    		"WHERE 1=1 AND {$wpdb->users}.ID IN (
    	        SELECT {$wpdb->usermeta}.user_id
    		FROM $wpdb->usermeta
    		WHERE {$wpdb->usermeta}.meta_key = '{$wpdb->prefix}capabilities'
    		AND {$wpdb->usermeta}.meta_value NOT LIKE '%administrator%')",
    	$user_search->query_where
            );
        }
    }
    add_action('pre_user_query','isa_pre_user_query');

    [Moderator Note: Please post code & markup between backticks or use the code button. Your posted code may now have been damaged by the forum’s parser.]

    but if my user use url mysitename/wp-admin/user-edit.php?user_id=1
    he can show admin profile and modify it,
    How can i hide this page at my new role and show the erroe message ‘You do not have permission to edit this user.’?

  • The topic ‘do not show administrator edit-profile page if current user is not administrator’ is closed to new replies.