mllapan (@mllapan)

Forum Replies Created

Viewing 3 replies - 1 through 3 (of 3 total)

  • mllapan
    Participant

    @mllapan

    Thanks again for the answer.
    Your code check if user is blocked.

    Should I write like if ($role == 'bbp_keymaster' || $role == 'bbp_moderator'|| $role == 'bbp_participant'|| $role == 'bbp_spectator' && $post_count > 4)

    Or I can use ! as counter statement to blocked somewhere in your code?


    mllapan
    Participant

    @mllapan

    Thanks @robin-w, can you also tell me how to apply this only on users that are not blocked?

    If user has no BLOCKED role and has 5 posts show them this.


    mllapan
    Participant

    @mllapan

    Thanks, but I found this is_bbpress function, and solved it.

    add_filter( 'the_content', 'post_ads_1_paragraph' );
     
    function post_ads_1_paragraph( $content ) {
        $ad_code = '<div class="advert" style="display: none;">Reklama1</div>';
     
        if ( is_single() && ! is_admin() && ! is_bbpress() ) {
            return prefix_insert_after_1nd_paragraph( $ad_code, 1, $content );
        }
    	
        return $content;
    }
      
    function prefix_insert_after_1nd_paragraph( $insertion, $paragraph_id, $content ) {
        $closing_p = '</p>';
        $paragraphs = explode( $closing_p, $content );
        foreach ($paragraphs as $index => $paragraph) {
     
            if ( trim( $paragraph ) ) {
                $paragraphs[$index] .= $closing_p;
            }
     
            if ( $paragraph_id == $index + 1 ) {
                $paragraphs[$index] .= $insertion;
            }
        }
         
        return implode( '', $paragraphs );
    }
Viewing 3 replies - 1 through 3 (of 3 total)