bbp_admin_upgrade_remove_forum_subscriptions_from_usermeta()
Remove topic subscriptions data from user meta for bbPress 2.6 and higher
Description Description
Return Return
(array) An array of the status code and the message
Source Source
File: includes/admin/tools/upgrade.php
function bbp_admin_upgrade_remove_forum_subscriptions_from_usermeta() {
// Define variables
$bbp_db = bbp_db();
$statement = esc_html__( 'Remove forum subscriptions from usermeta… %s', 'bbpress' );
$result = esc_html__( 'No forum subscriptions to remove.', 'bbpress' );
$total = 0;
$key = $bbp_db->prefix . '_bbp_forum_subscriptions';
// Query
$query = "SELECT * FROM {$bbp_db->usermeta} WHERE meta_key = %s ORDER BY user_id";
$prepare = $bbp_db->prepare( $query, $key );
$subs = $bbp_db->get_results( $prepare );
// Bail if no forum favorites found
if ( empty( $subs ) || is_wp_error( $subs ) ) {
return array( 1, sprintf( $statement, $result ) );
}
// Delete all user-meta with this key
delete_metadata( 'user', false, $key, false, true );
$total = count( $subs );
// Complete results
$result = sprintf( _n( 'Complete! %d forum subscription deleted.', 'Complete! %d forum subscriptions deleted.', $total, 'bbpress' ), bbp_number_format( $total ) );
return array( 0, sprintf( $statement, $result ) );
}
Changelog Changelog
| Version | Description |
|---|---|
| 2.6.0 | Introduced. |