WordPress.org

Ready to get started?Download WordPress

Forums

Custom Content Type Manager
[resolved] Relation field -> Hide other's Private posts (8 posts)

  1. Rajesh Soni
    Member
    Posted 1 year ago #

    Hello,

    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?

    Thanks.

    http://wordpress.org/extend/plugins/custom-content-type-manager/

  2. fireproofsocks
    Member
    Plugin Author

    Posted 1 year ago #

    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.

  3. Rajesh Soni
    Member
    Posted 1 year ago #

    Thanks for your reply, I appreciate.

    I eventually had to modify the plugin to get it work.

    Here's what I did:

    File: custom-content-type-manager/ajax-controllers/get_posts.php
    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.

    Cheers!

  4. fireproofsocks
    Member
    Plugin Author

    Posted 1 year ago #

    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.

  5. Rajesh Soni
    Member
    Posted 1 year ago #

    For sure, will do that.

    Do you think, this approach of mine is better, mass-usable?

  6. Rajesh Soni
    Member
    Posted 1 year ago #

    Just wondering, should this be reported as a Bug?
    I see no option for "Feature request".

    Thanks.

  7. fireproofsocks
    Member
    Plugin Author

    Posted 1 year ago #

    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. ;)

  8. Rajesh Soni
    Member
    Posted 1 year ago #

    Gotcha!

Topic Closed

This topic has been closed to new replies.

About this Plugin

About this Topic