Is there a way to limit number of Questions?

3.52K viewsGeneral
0

Hello. On my website I limit users with ability to post 2 articles.
I’m using code in functions.php

// LIMIT number of posts per user
function post_published_limit( $ID, $post ) {
    $max_posts = 2; // change this or set it as an option that you can retrieve.
    $author = $post->post_author; // Post author ID.
    $count = count_user_posts( $author, 'post'); // get author post count
     if ( $count > $max_posts ) {
        // count too high, let's set it to draft.
        $post->post_status = 'draft';
        wp_update_post( $post);
  // add here
  // $redirecturl = get_post_type_archive_link( 'property' );
wp_redirect( site_url('/limit-2-maximum/' ));
exit;
  // end here adding
    }
}
add_action( 'publish_post', 'post_published_limit', 10, 3 );
// END LIMIT number of posts per users


My question: is there a way to utilize this code snippet to limit the number of Questions and/or Answers a user (member) can post?
Thank you.
PS just an amazing plugin, for sure!

Answered question
0

Okay, will flip snippet in a few days and report back. Thank you!