• Resolved mrgrumpy

    (@mrgrumpy)


    Hi,

    how can I hide the user profil page for individual user rolls?
    I don’t want them to be able to edit their profil at all.

    • This topic was modified 3 years, 9 months ago by mrgrumpy.
Viewing 1 replies (of 1 total)
  • Plugin Author Caseproof

    (@caseproof)

    Hi @mrgrumpy

    If you want to block access to admin for all roles except admin, you can add this code at the end of your theme’s functions.php file:

    
    add_action('admin_init', 'redirect_non_admin_users');
    function redirect_non_admin_users() {
    if ( ! current_user_can( 'manage_options' ) && ('/wp-admin/admin-ajax.php' != $_SERVER['PHP_SELF']) ) {
      wp_redirect( home_url() );
      exit;
      }
    }

    If you want to block a specific admin menu, you can try this code:

    
    add_action( 'admin_menu', 'members_remove_menu_pages' );
    function members_remove_menu_pages() {
      $user = wp_get_current_user();
      if ( in_array('subscriber', $user->roles) ) {
        remove_menu_page('users.php');
      }
    }

    Kind regards

Viewing 1 replies (of 1 total)
  • The topic ‘Hide user profil page’ is closed to new replies.