Support

Account

Home Forums Backend Issues (wp-admin) Backend shows information only of own user Reply To: Backend shows information only of own user

  • A quick snippet for you:

    add_action( 'pre_get_posts', 'filtre');
    function filtre($query) {
       //echo '<pre>'.print_r($query->query_vars['post_type'], true).'</pre>';
    
        switch($query->query_vars['post_type']){
    
            
            case 'attachment':  // Media library
                if( current_user_can('manage_own_media') ) $query->set('author', get_current_user_id() );
                break;
            
            case 'post':        // Posts
                if( current_user_can('manage_own_posts') ) $query->set('author', get_current_user_id() );
                break;
    
            case 'page':        // Pages
                if( current_user_can('manage_own_pages') ) $query->set('author', get_current_user_id() );
                break; 
                
       } // switch post_type
        
        return $query;
    }

    Of course this is assuming that there are custom permissions set up using the User Role Editor!