Skip to:
Content
Pages
Categories
Search
Top
Bottom

How can I set up activity data from an array (of objects or IDs)?

  • Avatar of godavid33
    godavid33
    Participant

    @godavid33

    Given the following code:

    
    	do_action( 'bp_before_activity_loop' );
    	if ( bp_has_activities( bp_ajax_querystring( 'activity' )."&scope=groups") ) :
    		while ( bp_activities() ) : bp_the_activity();	
    				$act_ID = bp_get_activity_id();
    				$wall_activities[] = $act_ID; 	
    		endwhile;
    	endif;
    	do_action( 'bp_after_activity_loop' ); 
    

    How could I iterate over $wall_activities in a following foreach such that calling bp_get_activity_id() (in the subsequent foreach) would give me the appropriate ID from the array I defined? I know that I could just do what I need to do in the initial while, but I need to run multiple of while’s and then do some operations on the collected activity data.

Viewing 1 replies (of 1 total)
  • Avatar of godavid33
    godavid33
    Participant

    @godavid33

    To answer my own question, first:

    
    	//Get friends Loop
    	do_action( 'bp_before_activity_loop' );
    	if ( bp_has_activities( bp_ajax_querystring( 'activity' )."&scope=friends") ) :
    		$friends_activites = $activities_template->activities;
    	endif;
    	do_action( 'bp_after_activity_loop' ); 
    	
    	//Get personal Loop
    	do_action( 'bp_before_activity_loop' );
    	if ( bp_has_activities( bp_ajax_querystring( 'activity' )."&scope=just-me") ) :
    		$personal_activites = $activities_template->activities; 
    	endif;
    	do_action( 'bp_after_activity_loop' ); 
    

    Then:

    
    $activities_template->activities = array_merge($personal_activites,$friends_activites);
    

    Then loop:

    
    		<?php while ( bp_activities() ) : bp_the_activity(); ?>
    
    			<?php bp_get_template_part( 'activity/entry' ); ?>
    
    		<?php endwhile; ?>
    

    There might be a little I’m leaving out. If you view my profile and look at some of my forum activity you can probably find the whole code snippet. Too tired to post all of it.

Viewing 1 replies (of 1 total)

You must be logged in to reply to this topic.