WordPress.org

Ready to get started?Download WordPress

Forums

Exclude Posts in Dashboard based on User (4 posts)

  1. cjc1867
    Member
    Posted 9 months ago #

    Hi
    I would like to hide 4 posts from the Post Edit Screen in the Dashboard (not the homepage of the website or any other page) from other logged in Users, apart from myself.

    I don't want to password protect it or make it Private as the 4 posts are used on a Custom Dashboard page. If I can hide them then my client won't be able to edit them.

    How do I do it, been searching all day and can't find an answer.

    Colin

  2. Rod Whiteley
    Member
    Posted 9 months ago #

    My first thought is to filter posts_where when WP_ADMIN is defined, so as to exclude those post's IDs, but I haven't tried it.

  3. cjc1867
    Member
    Posted 9 months ago #

    Hi Rod
    I have tried the code but with no luck.

    I'm thinking of something like this to added into functions.php:

    /** Hide SuperAdmin Posts **/
    function hide_posts-unless_superadmin() {
        $userdata = wp_get_current_user();
        if ( $userdata->ID != 1 ) {
            some code to hide superadmin posts...
        }
    }
    
    add_action('admin_init', 'hide_posts-unless_superadmin');

    But I'm stuck and maybe barking up the wrong tree.

    Colin

  4. cjc1867
    Member
    Posted 9 months ago #

Reply

You must log in to post.

About this Topic

Tags

No tags yet.