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 only want a post to be viewable by the administrator and one user. (So I would have a post for each user)

I am thinking of using the Members plugin and meta-data/custom fields to restrict the content. This would effectively make the post private to only those with access and any one else would not even see the post and if they get the url, they will be denied.

So would using the Members plugin be the best choice or should I try a different method? and how?

share|improve this question
add comment

2 Answers

up vote 2 down vote accepted

I am not expert on users, simplest way as for me would be to store ID (or IDs) of user in custom field and check for it if user is not admin.

Some example code (not tested):

if(current_user_can('administrator') || in_array(get_current_user_id(), get_post_meta(get_the_id(), 'allowed_users', true))) {

    the_content();
}
else {

    echo 'Post restricted';
}
share|improve this answer
    
Thank you Rarst. I implemented a solution similar to the one you provided. –  imHavoc Jan 28 '11 at 4:07
1  
Any chance you could share with us the solution you implemented, @imHavoc? –  Beto Frega Nov 1 '11 at 16:59
add comment

Why don't you use plugin such as Role Manager? You can do that easily. =)

share|improve this answer
    
Can you link me to this plugin? I cannot find it in the WP Plugin Directory. Also note, I do not want to create a new Role for every user. –  imHavoc Dec 28 '10 at 3:48
    
im-web-gefunden.de/wordpress-plugins/role-manager You can specific users' roles in group. –  Luis Dec 28 '10 at 3:58
    
That's not quite what I am looking for. Each user will have their own post/multiple post. But those posts will be exclusively available to them and administrators. –  imHavoc Dec 28 '10 at 16:41
add comment

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.