• inkyone

    (@inkyone)


    I have noticed that the users of my website have the possibility to view the posts that have been left in the draft by the admin of the panel.

    I am not sure what is the reason that this function is in this state, but it seems to me that it is not right.

    Or maybe I did something wrong that I am not aware of, if not, then it would be good if someone from the developers would change this.

    Thank you

Viewing 5 replies - 1 through 5 (of 5 total)
  • Anton Vlasenko

    (@antonvlasenko)

    It shouldn’t happen.

    Are these users registered or guest users? If they are registered users, what role are they assigned?

    Go to Users > All Users in your WordPress dashboard and check their roles. Only administrators and editors should have access to drafts.

    Thread Starter inkyone

    (@inkyone)

    Hey @antonvlasenko , thanks for the reply.

    I see that I have set the users with the role of “Contributor” because I wanted the users to be able to create blog posts. I thought of just enabling the role of “Subscriber” but it seems, that with this role, the registered users, are unable to make blog posts.

    This leaves the role of a “Contributor” but still I just think that it’s inappropriate for the registered users to see what others have added to their draft.

    I realized that they can even see when a post is scheduled!

    Somehow I get it why this feature is added this way, but I cant think of any good reason for Contributors having the ability to see on the Dashboard what others have stored in draft.

    Maybe this would be appropriate if the rank would be set as Moderator for the users!

    Anton Vlasenko

    (@antonvlasenko)

    Sorry for the confusion. Yes, contributors can view other people’s draft posts; however, they can only see the titles, not the content. This is expected behavior.

    Unfortunately, there is no quick and easy fix for this.

    The solution below appears to restrict contributors from viewing other users’ posts (they can only see their own posts in the admin area), but it doesn’t always work correctly, as it sometimes shows an incorrect post count in the admin panel.

    // Restrict contributors to only view and edit their own posts
    function restrict_contributor_posts( $query ) {
    if ( ! is_admin() || ! $query->is_main_query() || ! current_user_can( 'contributor' ) ) {
    return;
    }

    global $pagenow;

    // Restrict contributors to only see their own posts in the post list
    if ( $pagenow == 'edit.php' ) {
    $query->set( 'author', get_current_user_id() );
    }
    }
    add_action( 'pre_get_posts', 'restrict_contributor_posts' );

    I’ve packaged it into a WordPress plugin so that you can install and try it. However, I bear no responsibility for its use (please proceed at your own risk): https://filebin.net/pq95kjuy25r1boop

    • This reply was modified 3 months ago by Anton Vlasenko. Reason: improved code
    Thread Starter inkyone

    (@inkyone)

    Hey @antonvlasenko .

    Thanks for this code but for now Ill just leave it as it is because I am not that good with mingling with code scripts. Hopefully this will change by the WP developers in the future and for now its good that there is a solution for when its most required.

    ?Hopefully this will change by the WP developers in the future and for now its good that there is a solution for when its most required.

    @inkyone To help ensure that WordPress developers are aware that this issue is still affecting users, I encourage you to share your experience on the relevant Trac ticket. The issue you’re encountering with the display of other users’ post titles is being discussed in this Trac ticket:?#8111, this comment specifically.

    By adding your comment to this ticket, you can help highlight the ongoing impact of this problem, which may prompt developers to prioritize a fix in future WordPress updates.

Viewing 5 replies - 1 through 5 (of 5 total)
  • You must be logged in to reply to this topic.