I have a “Relation” field, that has search_terms set to show ONLY “Private” posts (custom post type).
The logged in user should be able to see ONLY their private posts.
But, I am able to see other users’ private posts as well.
How do I hide private posts from OTHER users?
That’s a bit tricky… you could filter on the “author” column (you’d have to customize the form so that parameter was visible: https://code.google.com/p/wordpress-custom-content-type-manager/wiki/Config_post_selector_relation), but that still wouldn’t dynamically determine the current user’s ID. This would make a good feature request.
Thanks for your reply, I appreciate.
I eventually had to modify the plugin to get it work.
Here’s what I did:
I inserted my code before this line:
$hash['content'] .= CCTM::parse($item_tpl, $r);
// Rajesh Soni // 08 March 2013 // Hide Private posts from other users (for non-admin users) global $user_ID; if( !current_user_can("administrator") && $r['post_status'] == 'private' && $r['post_author'] != $user_ID) continue;
That seemed to do the trick!
— I can now ONLY see my own private posts
— I can see everybody’s private posts if logged in as an administrator
Let me know your thoughts.
If you took the time to hack the plugin, please take the time to file a feature request: your edits will be overwritten if/when you update the plugin to the next version.
For sure, will do that.
Do you think, this approach of mine is better, mass-usable?
Just wondering, should this be reported as a Bug?
I see no option for “Feature request”.
Report it as a bug — I can categorize it as a feature request later. Thanks.
As for “mass-appeal” — I don’t know. I rely on feature requests for that. 😉
- The topic ‘Relation field -> Hide other's Private posts’ is closed to new replies.