Support » Plugin: Co-Authors Plus » authors shall only see their own posts (where they are co-author)

  • Hey guys,

    first of all thanks for the good work! 🙂

    I would like to modify the wordpress backend in a way, so that users of a certain role can only see their own posts (and documents for that matter; I am using WP document revisions for that). There are not really any plugins for that (at least ones that are still maintained), however I found this piece of code that I put into my functions.php:

    function mypo_parse_query_useronly( $wp_query ) {
        if ( strpos( $_SERVER[ 'REQUEST_URI' ], '/wp-admin/edit.php' ) !== false ) {
            if ( !current_user_can( 'level_10' ) ) {
                global $current_user;
                $wp_query->set( 'author', $current_user->id );
    add_filter('parse_query', 'mypo_parse_query_useronly' );

    However, this piece of code doesn’t seem to work with coauthors plus: even though a certain user with the role “Editor” is coauthor of a post/document, he can not see the post. Since I am (unfortunately) a php/wordpress noob, I can’t figure it out…

    I would be very happy for any suggestions,

    thanks for the Help,


Viewing 3 replies - 1 through 3 (of 3 total)
  • Plugin Author Daniel Bachhuber


    Hand Built

    Can you instead try this?

    $wp_query->set( 'author_name', $current_user->user_nicename );


    I’ve got the same problem, I wanted the author to only see and edit their own posts and own media. I find this code that you can place at the beginning of your functions.php

    //restrict authors to only being able to view media that they've uploaded
    	function ik_eyes_only( $wp_query ) {
    		//are we looking at the Media Library or the Posts list?
    		if ( strpos( $_SERVER[ 'REQUEST_URI' ], '/wp-admin/upload.php' ) !== false
    		|| strpos( $_SERVER[ 'REQUEST_URI' ], '/wp-admin/edit.php' ) !== false ) {
    			//user level 5 converts to Editor
    			if ( !current_user_can( 'level_5' ) ) {
    				//restrict the query to current user
    				global $current_user;
    				$wp_query->set( 'author', $current_user->id );
    	//filter media library & posts list for authors
    	add_filter('parse_query', 'ik_eyes_only' );

    I hope it will help!

    Hey, I havent had the chance yet to check it out, but will do as soon as I have time! Anyway, thanks for the code!

    Cheers, Stefan

Viewing 3 replies - 1 through 3 (of 3 total)
  • The topic ‘authors shall only see their own posts (where they are co-author)’ is closed to new replies.