Viewing 3 posts - 1 through 3 (of 3 total)
  • Author
    Posts
  • #1158864

    Hi,

    we have tested the following code ( https://kriesi.at/support/topic/remove-layout-elements-per-user-role/#post-492610), but it does not work. Is the code correct?

    add_filter('admin_head', 'avf_builder_button_params_mod', 10, 1);
    function avf_builder_button_params_mod($params) {
      $user = wp_get_current_user();
      if ( in_array( 'administrator', (array) $user->roles ) ) {
        echo '<style type="text/css">.copyright{display: none !important;}';
      }
    }

    Thanks for your help

    • This topic was modified 4 years, 10 months ago by Tobias.
    #1158900

    Hi,

    I’ve found a solution. Filter admid_head only affects the backend!

    My solution is:

    function role_admin_body_class( $classes ) {
        global $current_user;
        foreach( $current_user->roles as $role )
            $classes .= ' role-' . $role;
        return trim( $classes );
    }
    add_filter( 'body_class','add_body_classes' );
    function add_body_classes( $classes ) {
        $classes[] = 'admin_class';
        return $classes;
    }

    This allows another class in the body. You can use it to show and/or hide elements by user.

    Many greetings

    #1158908

    Hi,

    I’m glad this was resolved. If you need additional help, please let us know here in the forums.

    Best regards,
    Jordan Shannon

Viewing 3 posts - 1 through 3 (of 3 total)
  • The topic ‘Different CSS for users’ is closed to new replies.