How to restrict subscriber editing other posts but read specific posts in backend

Question

I need to allow Subscribers to edit their posts (done) and read (see in backend) posts of specific author or with specific ID (to make copies of it). I found the code, but that’s not enough:

function posts_for_current_author ($query) {
        if( $query->is_admin && 'edit.php' == $GLOBALS['pagenow'] && !current_user_can( 'edit_others_posts' ) ) {
            $query->set('author', $GLOBALS['user_ID'] );
        }
        return $query;
    };
    add_filter('pre_get_posts', 'posts_for_current_author');
0
, Juliana Jul 1 year 2020-07-23T14:11:16-05:00 0 Answers 55 views 0

Leave an answer

Browse
Browse