- This topic has 2 replies, 3 voices, and was last updated 4 years, 4 months ago by .
Viewing 3 posts - 1 through 3 (of 3 total)
Viewing 3 posts - 1 through 3 (of 3 total)
- You must be logged in to reply to this topic.
Support site for Tips and Tricks HQ premium products
by
Tips and Tricks HQ Support Portal › Forums › WP eMember › Protecting post custom fields
Hi there,
I have a custom post type that I am protecting using category protection. Each of my membership levels grants access to a single category.
This is working ok for protecting the body content of my posts.
But I also have some custom fields with these posts and these are not being protected. When viewing each single post, anybody with any membership level can see the custom fields, not just those with the correct membership level.
My problem is like in this thread: https://support.tipsandtricks-hq.com/forums/topic/emember-protecting-content-outside-a-post-custom-fields-and-shortcodes
The [emember_protected] shortcode does not protect my custom fields.
I need some way to check if the member has the correct access level to view the custom fields associated with the post.
The logic is like:
If member has access to this post, then show custom fields (else hide custom fields)
I can’t hard code it for every posts, it has to be a dynamic solution.
Are you trying to protect a post, based on the contents of custom fields?
The contents of a post are rendered by a WordPress function called the_content(). When an entire post is protected (post or category wise), membership levels are checked before the_content() is executed. When “partial protection” is used to protect sections of a post, membership levels are checked during execution of the_content() via the interpretation of shortcodes contained in the post.
Custom fields are considered meta data, and are stored in the_meta() of each post. Unfortunately, there is no structured way how your theme or plugin may output the custom meta data from the custom post (whether it will output any, some or all). So our plugin does not have a way to check that and protect it by default.
Are you using a theme template that is displaying the custom field contents, and you don’t want them displayed?
This kind of customization will need to be custom coded. I think you will most likely need a custom version of the following addon: