0

I want to allow a user only to see and edit one single page in the backend.

Means:
user 1 can edit and see page #20
user 2 can edit and see page #21

The other pages, posts, settings can not be entered, seen or edited by these users.

any ideas?

In the frontend everyone of these users has one page. It is for a customer who has 20 customers who should have their own personal page.

1 Answer 1

1

You can enhance the query for backend. The follow source add the user id to the SQL selct for list posts and remove all posts, there are from other user IDs. List only the posts from the logged in users. But the administrator have full access, he is exclude from this enhancement.

add_filter( 'posts_where', 'fb_add_posts_where' );
function fb_add_posts_where( $where ) {

    if ( ! is_admin() || current_user_can( 'administrator' ) )
        return $where;

    $current_user = wp_get_current_user();
    $where .= ' AND post_author = ' . $current_user->ID;

    //var_dump($where);exit;
    return $where;
}

You can enhance this example for much more requirements.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.