Skip to:
Content
Pages
Categories
Search
Top
Bottom

Reply To: Buddypress activity filtering (search)

@brgweb

Participant

This is the code I added at line 278 in /wp-content/plugins/buddypress-activity-plus/lib/class_bpfb_binder.php to create the action. The credit for this code is @Juanma in WordPress.org forum. (couldn’t find the original thread). In this case I’m creating an action for images upload.

function ajax_update_activity_contents () {
  $bpfb_code = $activity = '';
  $aid = 0;
  $codec = new BpfbCodec;
  if (@$_POST['data']['bpfb_photos']) {
    $images = $this->move_images($_POST['data']['bpfb_photos']);
    $bpfb_code = $codec->create_images_tag($images);
    $type = 'bpfb_share_wall_photos';
  }

  $bpfb_code = apply_filters('bpfb_code_before_save', $bpfb_code);

  // All done creating tags. Now, save the code
  $gid = (int)@$_POST['group_id'];
  if ($bpfb_code) {
    global $bp;
    $content = @$_POST['content'] . "\n" . $bpfb_code;
    $content = apply_filters('bp_activity_post_update_content', $content);
    $user_id = $bp->loggedin_user->id;
    $userlink = bp_core_get_userlink( $user_id );

    $author = bp_core_get_userlink( $author_id );
    $activity_url = bp_activity_get_permalink( $item_id );

    $aid = $gid ?
      groups_post_update(array('conte nt' => $content, 'group_id' => $gid)) : 
      bp_activity_add(
        array(
          'action' => apply_filters( 'activity_update', sprintf( __( '%s shared a link', 'buddypress' ), $userlink ), $user_id ),
          'content' => $content,
          'component' => 'activity',
          'type' => $type,
          'user_id' => $user_id
        )
      );
      if ($aid) {
			ob_start();
			if ( bp_has_activities ( 'include=' . $aid ) ) {
				while ( bp_activities() ) {
					bp_the_activity();
					if (function_exists('bp_locate_template')) bp_locate_template( array( 'activity/entry.php' ), true );
					else locate_template( array( 'activity/entry.php' ), true );
				}
			}
			$activity = ob_get_clean();
		}
		header('Content-type: application/json');
		echo json_encode(array(
			'code' => $bpfb_code,
			'id' => $aid,
			'activity' => $activity,
		));
		exit();
	}
}

And this is the code that works for activity stream. It shows just the activities with this action, but when you click the ‘load more’ button it loads the regular stream.
<?php if ( bp_has_activities( bp_ajax_querystring( 'activity' ) . '&action=bpfb_share_wall_photos') ) : ?>

Skip to toolbar