Ticket #7382: 7382.01.patch
| File 7382.01.patch, 3.3 KB (added by , 10 years ago) |
|---|
-
src/bp-groups/bp-groups-functions.php
1625 1625 if ( ! bp_is_item_admin() ) 1626 1626 return false; 1627 1627 1628 $member = new BP_Groups_Member( $user_id, $group_id );1628 $member = new BP_Groups_Member( $user_id, $group_id, false, true, array( 'populate_user_object' => false ) ); 1629 1629 1630 1630 // Don't use this action. It's deprecated as of BuddyPress 1.6. 1631 1631 do_action( 'groups_premote_member', $group_id, $user_id, $status ); -
src/bp-groups/classes/class-bp-groups-member.php
135 135 * Constructor method. 136 136 * 137 137 * @since 1.6.0 138 * @since 2.8.0 Introduce $options as a parameter. 138 139 * 139 140 * @param int $user_id Optional. Along with $group_id, can be used to 140 141 * look up a membership. … … 143 144 * @param int|bool $id Optional. The unique ID of the membership object. 144 145 * @param bool $populate Whether to populate the properties of the 145 146 * located membership. Default: true. 147 * @param array $options { 148 * An array of additional options. 149 * @var bool $populate_user_object If $populate is set to true, whether we should do an additional 150 * query for the BP_Core_User object in the populate() method. Default: 151 * true. 152 * } 146 153 */ 147 public function __construct( $user_id = 0, $group_id = 0, $id = false, $populate = true ) { 154 public function __construct( $user_id = 0, $group_id = 0, $id = false, $populate = true, $options = array() ) { 155 // Set options. 156 $populate_user = true; 157 if ( isset( $options['populate_user_object'] ) && false === $options['populate_user_object'] ) { 158 $populate_user = false; 159 } 148 160 149 161 // User and group are not empty, and ID is. 150 if ( ! empty( $user_id ) && !empty( $group_id ) && empty( $id ) ) {162 if ( ! empty( $user_id ) && ! empty( $group_id ) && empty( $id ) ) { 151 163 $this->user_id = $user_id; 152 164 $this->group_id = $group_id; 153 165 154 if ( ! empty( $populate ) ) {155 $this->populate( );166 if ( ! empty( $populate ) ) { 167 $this->populate( $populate_user ); 156 168 } 157 169 } 158 170 159 171 // ID is not empty. 160 if ( ! empty( $id ) ) {172 if ( ! empty( $id ) ) { 161 173 $this->id = $id; 162 174 163 if ( ! empty( $populate ) ) {164 $this->populate( );175 if ( ! empty( $populate ) ) { 176 $this->populate( $populate_user ); 165 177 } 166 178 } 167 179 } … … 170 182 * Populate the object's properties. 171 183 * 172 184 * @since 1.6.0 185 * @since 2.8.0 Introduce $populate_user parameter. 186 * 187 * @param bool $populate_user Whether we should query for the BP_Core_User object. Default: true. 173 188 */ 174 public function populate( ) {189 public function populate( $populate_user = true ) { 175 190 global $wpdb; 176 191 177 192 $bp = buddypress(); … … 198 213 $this->comments = $member->comments; 199 214 $this->invite_sent = (int) $member->invite_sent; 200 215 201 $this->user = new BP_Core_User( $this->user_id ); 216 if ( $populate_user ) { 217 $this->user = new BP_Core_User( $this->user_id ); 218 } 202 219 } 203 220 } 204 221