Does MB Front End submission work with User Posts Limit

Support MB Frontend Submission Does MB Front End submission work with User Posts LimitResolved

Viewing 6 posts - 1 through 6 (of 6 total)
  • Author
    Posts
  • #42395
    Salony MohantySalony Mohanty
    Participant

    I would like to limit the number of custom posts that a user can post and view on the dashboard. I am using User Posts Limit plugin and it is working fine.

    If I create the custom posts using MB front end so dashboard is automatic, will the limits set by User Posts Limit still apply?

    I am assuing and hoping yes but wanted to confirm.

    #42396
    Salony MohantySalony Mohanty
    Participant

    If there any filter that Metabox has to put a programmatic limit please suggest

    #42410
    PeterPeter
    Moderator

    Hello,

    Meta Box does not support limiting users from creating posts. You can try to use the if statement to check if the user has a post or a number of posts and then output the frontend submission form or not. Please refer to this topic https://wordpress.stackexchange.com/questions/139818/check-if-current-user-has-post-in-post-type-and-is-author-role

    #42411
    Salony MohantySalony Mohanty
    Participant

    Thanks for he link.
    How do we control whether the form will render or not through code? could you please provide a snippet?

    #42427
    PeterPeter
    Moderator

    Hello,

    In the page template, you can use the code in the topic above to check the number of posts belonging to a user then output the frontend form shortcode. For example:

    if( check_the_number_of_posts_here ) {
    echo do_shortcode( '[mb_frontend_form id="field-group-id" post_fields="title,content"]' );
    }

    If you are not able to complete the task, please contact us here https://metabox.io/contact/
    Our development team will help you with an extra fee.

    #42829
    pluginovenpluginoven
    Participant

    For limiting a user to only create X amount of posts, we are using the mbfs_dashboard_add_new_button filter like so:

    add_filter( 'mbfs_dashboard_add_new_button', 'limit_num_of_workplaces', 20, 2 );
    function limit_num_of_workplaces( $add_new_button, $atts ) {
    	if( $atts['post_type'] == 'workplace' && current_user_can('some_user_role') ){
    		//how many workplaces does this user have? (we are limiting to 3)
    		if (count_user_posts( get_current_user_id(), $atts['post_type'], false ) > 2 ){
    			$add_new_button = ''; //no soup for you!
    		}
    		return $add_new_button;
    	}
    }
Viewing 6 posts - 1 through 6 (of 6 total)
  • You must be logged in to reply to this topic.