Skip to:
Content
Pages
Categories
Search
Top
Bottom

If user has X number of posts?


  • mllapan
    Participant

    @mllapan

    How do I check if user has X number of posts inside bbpress forum to allow him to see blog post.
    For example, for logged in user, it would be like:

    function show_to_logged( $atts, $content = null ) {
    if ( is_user_logged_in() ) {
        echo 'Welcome, registered user!';
    } else {
        echo 'Welcome, visitor!';
    };
    
    add_shortcode('show_to_logged', 'show_to_logged');
    function show_to_bbpress_user_with_x_posts( $atts, $content = null ) {
    if ( user_has_X_BBPRESS_topics_or_topic_replies() ) {
        echo 'Welcome, registered user!';
    } else {
        echo 'Welcome, visitor!';
    };
    
    add_shortcode('show_to_bbpress_user_with_x_posts', 'show_to_bbpress_user_with_x_posts');

    What would be correct function for user_has_X_BBPRESS_topics_or_topic_replies?

Viewing 1 replies (of 1 total)

  • Robin W
    Moderator

    @robin-w

    so something like

    $user_id = get_current_user_id()  ;
    $topic_count  = bbp_get_user_topic_count_raw( $user_id);
    $reply_count = bbp_get_user_reply_count_raw( $user_id);
    $post_count   = (int) $topic_count + $reply_count;		
    if ($post_count > 150) { 
    //show here
    }
Viewing 1 replies (of 1 total)
  • You must be logged in to reply to this topic.
Skip to toolbar