BuddyDev

Search

How to restrict access to custom post typep based on blog post count


  • Participant
    Level: Master
    Posts: 152
    Tosin on #20169

    Hello,

    I have a post type on my site called classified

    Please how can I restrict access to the classified post type based on the total number of published blog post of a logged in user.

    The user must have published minimum of 5 blog posts before they can view or access classifieds on the site.

    When the user try to view or access a classified they will see this error message (Hello -username-, you need to publish at least 5 high quality articles before you can view this classified)

    I am using a frontend editor plugin for user generated content

    Thanks


  • Keymaster
    (BuddyDev Team)
    Posts: 13456
    Brajesh Singh on #20187

    Hi Tosin,
    Since the plugin involved are not related to us, I will suggest contacting the front end plugin’s team for the assistance.

    Regards
    Brajesh


  • Participant
    Level: Master
    Posts: 152
    Tosin on #20222

    Hello Brajesh,

    I am not reffering to a specific plugin, I don’t have any classified plugin installed, but im reffering to any custom post type that will be created, the earlier classified was just used as an example of a custom post type, it could be any custom post type. e.g reviews, books, cars etc

    Thanks


  • Participant
    Level: Master
    Posts: 152
    Tosin on #20458

    Hello Brajesh,

    Any feedback on this issue

    Thank you


  • Keymaster
    (BuddyDev Team)
    Posts: 13456
    Brajesh Singh on #20466

    Hi Tosin,
    If you are looking for conditions then here is an example

    
    
    if ( count_user_posts( get_current_user_id(), 'your_post_type' ) > 10 ) {
    	// do something.
    }
    
    

    Change the post type and count.

    Rest of the implementation details you will need to handle.

    Regards
    Brajesh

You must be logged in to reply to this topic.

This topic is: not resolved
Subscribe