How can user access only specific custom post type?

Hi There. I have WPMU setup and on one website I have specific post type I want user to access. For example classifieds. How can I setup permission, so when new user is register on this website - he/she can ONLY add his own classified ads, edit them, upload files and remove them. But he can't of course access and edit classified ads by other users. Please note I won't use classifieds, by my custom post type. Thanks a lot.
Regards, Dean

  • deanl

    Hi Tom,

    Thanks for reply. It's on MU setup. Not using "pro sites/ membership". I need very specific content type. Please hold with me on this one - long description coming :slight_smile:

    So I used CustomPress to build. It's basically post with another 20 custom fields. Later I intend to come back and add more functions to this CPT. Also this CPT using main categories and tags on this website. This is one of 2 websites in the network.

    Now I want user to sing to any of 3 websites and get specific role (this is done and working with plugins "members" and "multisite user management"). On website 1, register user can only comment, on website 2 they can post this CPT (kind of classified ad) and also write blog posts (as this blog on website 2 will be dedicate to users to share their knowledge) and on website 3 there will be your Q&A plugin. So register user can post questions and give answers.

    Now note that someone can join any site they'll get this role called "Member" and be able to do above. Till now I did all sites and content type. Users can register now on all 3 sites and on all 3 sites they get correct role.

    Now, I need to set permissions, so on the site 2 they can access only their own posts - normal posts OR custom post type. Also is there a ways to keep one profile page for all 3 sites and when they get points in Q&A on site 3 to display this on this one, network wide profile?

    Thanks a lot. Hope above have sense. Cheers
    Dean

  • deanl

    yes, all good, thanks guys.
    and a little piece of code to share:

    function that will show posts only to author. worked for my CPT issues:slight_smile:

    ////////////////////////////////////////////////////

    function ik_eyes_only( $wp_query ) {
    //are we looking at the Media Library or the Posts list?
    if ( strpos( $_SERVER[ 'REQUEST_URI' ], '/wp-admin/upload.php' ) !== false
    || strpos( $_SERVER[ 'REQUEST_URI' ], '/wp-admin/edit.php' ) !== false ) {
    //user level 5 converts to Editor
    if ( !current_user_can( 'level_5' ) ) {
    //restrict the query to current user
    global $current_user;
    $wp_query->set( 'author', $current_user->id );
    }
    }
    }

    //filter media library & posts list for authors
    add_filter('parse_query', 'ik_eyes_only' );

    //////////////////////////////////////

Thank NAME, for their help.

Let NAME know exactly why they deserved these points.

Gift a custom amount of points.