Take the 2-minute tour ×
WordPress Development Stack Exchange is a question and answer site for WordPress developers and administrators. It's 100% free, no registration required.

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.

share|improve this question

1 Answer 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.

share|improve this answer

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

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