Skip to:
Content
Pages
Categories
Search
Top
Bottom

Reply To: Add New User Activity on Button Click

@sjs719

Participant

For example, I have tried the following code and tried to call it onClick but it either doesn’t register or throws an error:

function add_featured_activity(){

GLOBAL $wpdb;
$user_id = get_current_user_id();
$user_info = get_userdata( $user_id );

$button_action = "<a href='".site_url()."/members/".$user_info->user_login."'></a>";

// arguments to pass to the bp_activity_add() function
$args = array(
'action'            => $button_action,                     // The activity action - e.g. "Jon Doe posted an update"
'component'         => 'profile',                  // The name/ID of the component e.g. groups, profile, mycomponent
'type'              => 'activity_update',                  // The activity type e.g. activity_update, profile_updated
'user_id'           => $user_id,  // Optional: The user to record the activity for, can be false if this activity is not for a user.
'item_id'           => $user_id,                  // Optional: The ID of the specific item being recorded, e.g. a blog_id
'recorded_time'     => bp_core_current_time(), // The GMT time that this activity was recorded
'hide_sitewide'     => 0,                  // Should this be hidden on the sitewide activity stream?
'is_spam'           => 0,                  // Is this activity item to be marked as spam?
);

$add_activity = bp_activity_add($args);

// Update the members's last activity
update_last_activity( $user_id );

return true;
}  
add_action('bp_activity_add', 'add_featured_activity' );
Skip to toolbar