Tagged: enhancements activity
When a user joins a group, this is recorded in the activity stream:
<user> joined the group <group name>When a user leaves a group no corresponding activity is recorded. I think it should record
<user> left the group <group name>Rational:
(1) just as it is useful to know who has joined, so it is useful to know when someone leaves.
(2) I have seen a user join, make a posting and then leave. I doubt they intended to. It is not clear whether that was deliberate or they happened to click on ‘leave group’ when they just meant to quit the screen. If they had seen an activity record saying they had left, they might have realised what they had done.thanks
Hi Tony,
Thank you.I understand your point and will post the code sometime later today 🙂
@rugwarrior…Not leaned of any code for this.
I think it should become standard in BuddyPress and hope this thread has led to a change request.
@Tony The BuddyPress people are good guys (and girls). If it is not available I might post it as an idea.
Hi,
I am sorry, I missed to post.You can use the following code in your bp-custom.php to add a left group activity
function buddydev_group_leave_group_activity( $group_id, $user_id ) { // Bail if Activity is not active if ( ! bp_is_active( 'activity' ) ) { return false; } // Get the group so we can get it's name $group = groups_get_group( array( 'group_id' => $group_id ) ); $action = apply_filters_ref_array( 'groups_activity_left_group_action', array( sprintf( __( '%1$s left the group %2$s', 'buddypress' ), bp_core_get_userlink( $user_id ), '<a href="' . bp_get_group_permalink( $group ) . '">' . esc_attr( $group->name ) . '</a>' ), $user_id, &$group ) ); // Record in activity streams groups_record_activity( array( 'action' => $action, 'type' => 'left_group', 'item_id' => $group_id, 'user_id' => $user_id ) ); } add_action( 'groups_leave_group', 'buddydev_group_leave_group_activity', 10, 2 );
Hope that helps.
- This reply was modified 8 years, 8 months ago by Brajesh Singh. Reason: Updated the name of function to fix typo
You must be logged in to reply to this topic.