Skip to:
Content
Pages
Categories
Search
Top
Bottom

[Resolved] change bp_activity_content_body


  • shavonn4prez
    Participant

    @shavonn4prez

    I want to change the body that returns from bp_activity_content_body().

    I have custom post types in the stream. I want to get the URL or ID only returned so I can used that to get actual post info for the stream.

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

  • modemlooper
    Moderator

    @modemlooper

    function record_post_activity_content_update( $excerpt, $post_content, $activity ) {
    	global $post;
    	if( $post->post_type == 'post' ) {
    		$post_content= 	'<a href="' . get_permalink( $post->ID ) . '" class="activity-content-title" >' 
    						. get_the_post_thumbnail( $post->ID ) 
    						. get_post_field('post_title', $post->ID) . '</a>' 
    						.get_post_field('post_content', $post->ID);
    	}
    	return $post_content;
    }
    add_filter( 'bp_blogs_record_activity_content', 'record_post_activity_content_update');

    shavonn4prez
    Participant

    @shavonn4prez

    I put this in bp-custom. Is this correct? I also changed the post_type to mine which is tutorial but it doesn’t seem to be affecting the stream I have on the homepage.


    shavonn4prez
    Participant

    @shavonn4prez

    This is what I ended up doing for now if anyone cares 🙂

    <?php
    if (is_user_logged_in() && is_home()) {
      $user_id = get_current_user_id();
      $user=wp_get_current_user();
      $name=$user->display_name;
      $following_ids = bp_get_following_ids( array( 'user_id' => $user_id ) );
      $follows = implode( ',', (array) $following_ids );
      	$args = array (
          'max' => 5,
          'filter' => array(
            'user_id' => $follows,
            'action' => 'new_tutorial'
          )
      	);
    	$pre_rec = bp_activity_get($args);
    	$activities = $pre_rec['activities']; ?>
    <div class="container-fluid follow-updates">
      <div class="row">
        <div class="col-md-12">
          <h2 class="sub-title"><?php echo $name ?> follows...</h2>
    <div class="container">
      <div class="row activity-row">
            <?php if($activities){
    
              foreach ($activities as $activity) {
                $postID = strip_tags($activity->secondary_item_id);
                $post = get_post($postID);
    
                include(TEMPLATEPATH."/partials/tutorial-block.php");
    
            			// 'ID'		=> strip_tags($activity->id),
            			// 'TYPE'		=> strip_tags($activity->type),
            			// 'TIME' 		=> strip_tags($activity->date_recorded),
            			// 'AUTHOR' 	=> strip_tags($activity->display_name),
            			// 'TITLE' 	=> strip_tags($activity->action),
            			// 'CONTENT' 	=> strip_tags($activity->content),
            			// 'ITEM_ID'	=> strip_tags($activity->item_id),
            			// 'REL_ID'	=> strip_tags($activity->secondary_item_id),
                }
    
             } else { ?>
               <p class="text-center"><?php _e('There are no recent posts of those you follow. Find new friends!'); ?></p>
             <?php } ?>
    
      </div>
    </div>
    
        </div>
      </div>
    </div>

    shavonn4prez
    Participant

    @shavonn4prez

    btw- that’s Buddypress Follows that I get the following IDs from.


    modemlooper
    Moderator

    @modemlooper

    well thats not really editing the activity content its a custom foreach loop 😉


    Ruhul Amin
    Participant

    @ruhul105


    shavonn4prez
    Participant

    @shavonn4prez

    @modemlooper I know! I tried the code you gave me but I couldn’t get it working. Time constraints involved.

Viewing 7 replies - 1 through 7 (of 7 total)
  • The topic ‘[Resolved] change bp_activity_content_body’ is closed to new replies.
Skip to toolbar