0

I need a way to protect access to custom fields within my posts. I've been looking at several plugs ins, but none seem quite right.

I do not need to protect the body of my post, just a set of custom fields. I need a "pay to access" button to appear if a user has not purchased the post.

Also, I need access to the field purchased only on a per post basis. I.E. Post Title #1 purchase does NOT also give access to fields in Post Title #2

My access to these fields within the posts needs to be set to $x.xx for 30 days or one month.

Can anyone please help? I'm about at the end of my rope.

1 Answer 1

0

This sounds like custom development work, I doubt there is a pre-built solution. At its most basic, I'd say you need to a membership solution. There are a several out there, some free, some premium.

Then in your front-end you can wrap the display of all the custom fields with current_user_can() using a capability that only that level has. For custom user roles you can probably just get away with:

if( current_user_can('gold_member') ) {
 echo 'whoa check this out';
} else {
  echo 'sorry, no need to be a gold member to see this';
}

EDIT

or to make it post specific:

if( current_user_can('read_post_14') ) {
 echo 'whoa check this out';
} else {
  echo 'sorry, no need to be a gold member to see this';
}

You'd have to create a new role for each post though.... possibly on the save_post hook. But I'm not sure how you'd assign the role to user when he/she pays for a specific post.

4
  • Hi, thank you for your response. That's a clever idea, however, the fields / posts I am wanting to protect will be numerous and added frequently. Also since I don't want one user group to be able to access all protected content on all posts, this doesn't seem like "the" solution. I sure wish it was :(
    – streetfire
    Aug 13, 2014 at 20:31
  • If you mean you want different levels of protected custom fields then you are getting even more custom and I think you are looking at hiring a developer. I'm curious about your use case though, because it is one I haven't seen before. Aug 13, 2014 at 21:07
  • I would be happy to explain the use case in detail via email, but not here ;) The jist is that the post content will be accessible via membership level. Custom fields will output specific content as sort of an upgrade. The fields on each post will have different uploaded content related to the specific post... hence why the fields need purchased on a per post basis.
    – streetfire
    Aug 13, 2014 at 21:18
  • Well if you'd like to explain further you can email me here. Aug 13, 2014 at 21:59

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.