Let me correct my self, I’ve found the hook that fires after the activity has been deleted and it returns row id.
“bp_activity_action_delete_activity”
I’ve tried all of these hooks an some of them are firing but none of them are providing activity_id (INT). ROW id.
//Should fire after activity post saved/updated
// do_action( ‘bp_activity_posted_update’, $content, $user_id, $activity_id );`
// do_action( ‘bp_groups_posted_update’, $content, $user_id, $group_id, $activity_id );
// do_action( ‘bp_activity_add’, $r, $activity->id );
// do_action( ‘bp_activity_posted_update’, $r[‘content’], $r[‘user_id’], $activity_id );
// do_action( ‘bp_activity_post_type_published’, $activity_id, $post, $activity_args );
// do_action( ‘bp_activity_post_type_updated’, $post, $activity, $activity_post_object );
This one also isn’t working:
// define the bp_activity_after_save callback
function action_bp_activity_after_save( $rtmedia_bp_activity_after_save_callback, $int_val1, $int_val2 ) {
// make action magic happen here...
};
// add the action
add_action( 'bp_activity_after_save', 'action_bp_activity_after_save', 10, 3 );
Is there at least one hook that will provide row id on bp group activity after a post is saved?
This works as expected:
function test_bp_activity_add( $r, $activity_id ) {
write_log( $activity_id );
write_log( $r );
}
add_action( 'bp_activity_add', 'test_bp_activity_add', 99, 2 );
//do_action( 'bp_activity_add', $r, $activity->id );
From the log:
[28-Nov-2019 12:56:39 UTC] 419
[28-Nov-2019 12:56:39 UTC] Array
(
[id] =>
[action] =>
[content] => Test action hook on Group activity update
[component] => groups
[type] => activity_update
[primary_link] =>
[user_id] => 1
[item_id] => 1
[secondary_item_id] =>
[recorded_time] => 2019-11-28 12:56:39
[hide_sitewide] =>
[is_spam] =>
[error_type] => bool
)
So just set a conditional to check if $r['component'] == groups
and do whatever you want.
I see that hook “bp_activity_add” fires.
But it doesn’t return [id] value in your log.
Not returning row [id] is the issue.
The activity_id IS the row id, iow. the row id is 419
[28-Nov-2019 12:56:39 UTC] 419
All you have to do is try it yourself.
I’ve tried and it is working as it suppose to.
(I am not sure why it didn’t work at first but it is working now.)
Thanks!