Skip to:
Content
Pages
Categories
Search
Top
Bottom

Inject something after first activity (or inside latest activity?)


  • mllapan
    Participant

    @mllapan

    function buddydev_inject_content_after_n_activities() {
        static $current_activity_index = 1;
     
        // change $n to the correct number of activities.
        $n = 7; // After how many activities you want to inject content.
     
        if ( $current_activity_index % $n === 0 ) {
            ?>
            <li id="advertbuddy" class='activity-item activity-ad-item activity-custom-entry'>
                <?php echo adrotate_ad(7); ?>
            </li>
            <?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' );

    I tried using this, but when i click tabs on buddypress error availableWidth=0.
    Is there a function to use this code only on sitewide activity and to remove when tabs are changed, or to use any other similar function to inject ads into buddypress?

  • You must be logged in to reply to this topic.
Skip to toolbar