bp_groups_group_details_updated_add_activity( int $group_id, BP_Groups_Group $old_group, bool $notify_members )
Add an activity item when a group’s details are updated.
Description
Parameters
- $group_id
-
(Required) ID of the group.
- $old_group
-
(Required) Group object before the details had been changed.
- $notify_members
-
(Required) True if the admin has opted to notify group members, otherwise false.
Return
(null|WP_Error|bool|int) The ID of the activity on success. False on error.
Source
File: bp-groups/bp-groups-activity.php
644 645 646 647 648 649 650 651 652 653 654 655 656 657 658 659 660 661 662 663 664 665 666 667 668 669 670 671 672 673 674 675 676 677 678 679 680 681 682 683 684 685 686 687 688 689 690 691 692 693 694 695 696 697 698 699 700 701 702 703 704 705 706 707 708 709 710 | function bp_groups_group_details_updated_add_activity( $group_id , $old_group , $notify_members ) { // Bail if Activity is not active. if ( ! bp_is_active( 'activity' ) ) { return false; } if ( ! isset( $old_group ->name ) || ! isset( $old_group ->slug ) || ! isset( $old_group ->description ) ) { return false; } // If the admin has opted not to notify members, don't post an activity item either. if ( empty ( $notify_members ) ) { return ; } $group = groups_get_group( array ( 'group_id' => $group_id , ) ); /* * Store the changed data, which will be used to generate the activity * action. Since we haven't yet created the activity item, we store the * old group data in groupmeta, keyed by the timestamp that we'll put * on the activity item. */ $changed = array (); if ( $group ->name !== $old_group ->name ) { $changed [ 'name' ] = array ( 'old' => $old_group ->name, 'new' => $group ->name, ); } if ( $group ->slug !== $old_group ->slug ) { $changed [ 'slug' ] = array ( 'old' => $old_group ->slug, 'new' => $group ->slug, ); } if ( $group ->description !== $old_group ->description ) { $changed [ 'description' ] = array ( 'old' => $old_group ->description, 'new' => $group ->description, ); } // If there are no changes, don't post an activity item. if ( empty ( $changed ) ) { return ; } $time = bp_core_current_time(); groups_update_groupmeta( $group_id , 'updated_details_' . $time , $changed ); // Record in activity feeds. return groups_record_activity( array ( 'type' => 'group_details_updated' , 'item_id' => $group_id , 'user_id' => bp_loggedin_user_id(), 'recorded_time' => $time , ) ); } |
Changelog
Version | Description |
---|---|
BuddyPress 2.2.0 | Introduced. |
Questions?
We're always happy to help with code or other questions you might have! Search our developer docs, contact support, or connect with our sales team.