BuddyDev

Search

Replies

  • Participant
    Level: Initiated
    Posts: 5
    lucas on #20821

    thanks for the reply
    well i customize a bit but i have also tried it with the original code you gave but problem still exist. well the problem is that when you are on site wide activity stream when you click on my friend activity it shows a blank page and until you refresh
    ok i am sharing the code i am using.

    
    function buddydev_inject_content_after_n_activities() {
        static $current_activity_index = 1;
     
        // change $n to the correct number of activities.
        $n = 5; // After how many activities you want to inject content.
     if ( !is_user_logged_in()){   //i added it to show ads only to non-logged in user
        if ( $current_activity_index % $n === 0 ) {
    		 ?>
                <div class="activity-avatar">
    		
    		<div class="names"style="color:#c92e2e;">Sponsored</div>
    			<div class="nices-name">@sponsored</div>
    		</div>
    			<div class="activity-content">
    			<div class="ads"><script async adsense code //this the adsense script
    </script></div>
            </div><?php
            // show the activity injected content.
        }}
        // increment the current index.
        $current_activity_index ++;
     
    }
     
    add_action( 'bp_after_activity_entry', 'buddydev_inject_content_after_n_activities' );
    
  • Participant
    Level: Initiated
    Posts: 5
    lucas on #20812

    the problem start when you start using adsense code otherwise it work smoothly

  • Participant
    Level: Initiated
    Posts: 5
    lucas on #20811

    thanks brajesh for the code but problem still exist when you click on my friend activity from actvity stream or use any filter the actvity stream don’t load you have to refresh it.

  • Participant
    Level: Initiated
    Posts: 5
    lucas on #20808

    thanks brajesh i will be waiting for it