BBP_User_Engagements_User::remove_all_users_from_all_objects( string $meta_key = '', string $meta_type = 'post' )
Remove all users from all objects
Description Description
Parameters Parameters
- $meta_key
-
(Optional) The relationship key
Default value: ''
- $meta_type
-
(Optional) The relationship type (usually 'post')
Default value: 'post'
Return Return
(bool) Returns true on success, false on failure
Source Source
File: includes/common/engagements.php
public function remove_all_users_from_all_objects( $meta_key = '', $meta_type = 'post' ) { // Query for users $option_key = $this->get_user_option_key( $meta_key, 0, true ); $bbp_db = bbp_db(); $user_ids = $bbp_db->get_col( "SELECT user_id FROM {$bbp_db->usermeta} WHERE meta_key = '{$option_key}'" ); $u_count = count( $user_ids ); // Count number of removals $removed = array(); $r_count = 0; // Users have engaged, so remove them if ( ! empty( $u_count ) ) { // Loop through users and remove their user options foreach ( $user_ids as $user_id ) { $removed[] = $this->remove_user_from_all_objects( $user_id, $meta_key ); } // Count the removed users $r_count = count( $removed ); } // Return true if successfully removed from all users return ( $r_count === $u_count ); }
Changelog Changelog
Version | Description |
---|---|
2.6.0 | Introduced. |