Forum Replies Created

Viewing 2 replies - 1 through 2 (of 2 total)
  • Thread Starter Melita Poropat

    (@mebo)

    Hopefully someone from Yoast will do something for Premium sub menu pages so that we can easily hide it for some users. For now this is considered to be resolved from my perspective

    Thread Starter Melita Poropat

    (@mebo)

    So I found a solution that works for this case. Basicly added class to body element for logged in user and than with css used display none property. Good enough for now untill Yoast implements something for Premium submenu links in future.

    This is the code:

    //solution based on https://gist.github.com/jancbeck/3178689?permalink_comment_id=3083404#gistcomment-3083404
    
    add_filter("admin_body_class", function($classes) {
    
        $user = wp_get_current_user();
    
        foreach ($user->roles as $user_role) {
    
          $classes .= " user-role-{$user_role}";
    
        }
    
        return $classes;
    
      });
    
    // hide Premium Yoast sub pages for editor
    
    function add_custom_css_for_editor() {
    
        if (is_admin() && current_user_can('editor')) {
    
            echo '<style>';
    
            echo 'body.user-role-editor #toplevel_page_wpseo_workouts {';
    
            echo '    display: none !important;';
    
            echo '}';
    
            echo '</style>';
    
        }
    
    }
    
    add_action('admin_head', __NAMESPACE__ . '\\add_custom_css_for_editor');
Viewing 2 replies - 1 through 2 (of 2 total)