How to Create Social Activity Thread in Page/Post Specific by using Social Activity

Ultimate Member – Social Activity

It increase user engagement and allow users to interact with each other by sharing an activity system where users can create posts on their wall and see what other users are up to on your site.

Ultimate Member – Social Activity In specific page/post with different feed in different page

But for my client, I need to show this activity part for a specific page. Our main challenge was to have different activity feed for different page, which is not the by default.

Luckily Ultimate Member is coded in a such way that it was be extended.Even it’s add-ons too.

So now the task was to filters/hooks for it.
One hooks is um_activity_wall_args, which can be used to pass parameters.
In the below example we will filter activity post by meta_key.

add_filter('um_activity_wall_args', 'function_um_activity_wall_args',10,1);

* Filter to function_um_activity_wall_args
* @return array $args
function function_um_activity_wall_args($args) {
  global $post;

  if ( isset( $post->ID ) && ($post->ID == 9999 ) ) { // page id is 9999 with slug "events"
    $args['meta_query'][] = array('key' => '_page_slug','value' => '_umpage','compare' => '=');
  } else {
    $args['meta_query'][] = array('key' => '_page_slug','value' => '_notumpage','compare' => '=');

  return $args;

So here we are filter by meta_key. We are adding a meta_key : _page_slug and its value.

So depending upon the meta_query activity post will be shown.

Now the main challenge was to insert meta_value while activity posting.
Also there is a hook for it.

It calls when we do a ajax activity posting in wall. Sorry about the messed up code, as I did not find any way work with ajax calling. So using HTTP_REFERER to get current page url.


* Filter to um_activity_after_wall_post_published
* @return null
function function_um_activity_after_wall_post_published( $post_id ) {
  global $post;

  $page_url = esc_url( home_url( 'events/' ) ); 
  // page_id = 9999 and slug is events #

  if ( isset( $_SERVER[HTTP_REFERER] ) && ($_SERVER[HTTP_REFERER] == $page_url ) ) { // for page
    update_post_meta( $post_id, '_page_slug', '_umpage' );
  } else {
    update_post_meta( $post_id, '_page_slug', '_notumpage' ); // for except event tab
add_action( 'um_activity_after_wall_post_published', 'function_um_activity_after_wall_post_published' );

Leave a Reply

Your email address will not be published. Required fields are marked *