group details updated is not posting in activity stream. Or comments on blog
-
Currently when updating group details, it is not posting in sitewide activity stream or the groups home activity stream.
I have created a function for adding custom fields to create and edit groups and have currently added, record this to activity stream, for when group details are edited. Isn’t this supposed to be functioning anyway?
I am a very fast learner and have kinda got used to editing buddypress how I would like to without touching any source files.
Here is my current code I am using to insert my edits into the groups meta and insert the update into the activity stream.
add_action( 'groups_group_details_edited', 'group_details_update' ); function group_details_update( $group_id ) { global $bp, $wpdb; if ( !bp_current_user_can( 'bp_moderate' ) && !groups_is_user_member( bp_loggedin_user_id(), $group_id )) return false; $plain_fields = array( 'server', 'country' ); foreach( $plain_fields as $field ) { $key = 'group-' . $field; if ( isset( $_POST[$key] ) ) { $value = $_POST[$key]; if ($value == 'null') bp_core_add_message( __( 'There was an error updating group details. Please try again.', 'buddypress' ), 'error' ); else groups_update_groupmeta( $group_id, 'h1z1_' . $field, $value ); } } // Record this in activity streams $activity_action = sprintf( __( '%1$s has modified group %2$s', 'buddypress'), bp_core_get_userlink( bp_loggedin_user_id() ), '<a href="' . bp_get_group_permalink( $bp->groups->current_group ) . '">' . esc_attr( $bp->groups->current_group->name ) . '</a>' ); $activity_content = $content; $activity_id = groups_record_activity( array( 'user_id' => bp_loggedin_user_id(), 'action' => apply_filters( 'groups_activity_new_update_action', $activity_action ), 'content' => apply_filters( 'groups_activity_new_update_content', $activity_content ), 'type' => 'group_details_updated', 'item_id' => $group_id ) ); groups_update_groupmeta( $group_id, 'last_activity', bp_core_current_time() ); do_action( 'bp_groups_posted_update', $content, $user_id, $group_id, $activity_id ); }
This works when I edit the details of a group, but no activity is showing when I edit photo or settings.
I am assuming this is supposed to work out of the box, but doesn’t seem to be.
A few bugs I have found.
It posts when a member joins a group, but does nothing when they leave the group, they can keep joining and leaving and it will just post member has joined group multiple times. If the member is still in the group and I remove them from the group as an admin, it will then delete the streams that said the user joined, even if there is multiple it will remove them all.If I kick/ban the user, it will remove the streams also. If I unban, it will not post that a member has joined the group again. There are many functionality issues within the groups.
Are the problems above supposed to work and do work with the latest version of buddypress or do I have to hook bp_groups for each part that is not working as desired to add actions in my functions.php?
Thanks for reading my long post, hope someone can clear this up.
- The topic ‘group details updated is not posting in activity stream. Or comments on blog’ is closed to new replies.