bp_activity_favorites_upgrade_data()
Check if BuddyPress activity favorites data needs upgrade & Update to BuddyBoss activity like data
Description
Source
File: bp-activity/bp-activity-functions.php
function bp_activity_favorites_upgrade_data() { $bp_activity_favorites = bp_get_option( 'bp_activity_favorites', false ); if ( ! $bp_activity_favorites ) { $args = array( 'fields' => 'ID' ); // The Query $user_query = new WP_User_Query( $args ); // User Loop if ( $user_query->get_results() ) { foreach ( $user_query->get_results() as $user_id ) { $my_favs = bp_get_user_meta( $user_id, 'bp_favorite_activities', true ); if ( empty( $my_favs ) || ! is_array( $my_favs ) ) { continue; } foreach ( $my_favs as $fav ) { // Update the users who have favorited this activity. $users = bp_activity_get_meta( $fav, 'bp_favorite_users', true ); if ( empty( $users ) || ! is_array( $users ) ) { $users = array(); } // Add to activity's favorited users. $users[] = $user_id; // Update activity meta bp_activity_update_meta( $fav, 'bp_favorite_users', array_unique( $users ) ); } } bp_update_option( 'bp_activity_favorites', true ); } } }
Changelog
Version | Description |
---|---|
BuddyBoss 1.0.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.