129 | | // For legacy users. Use of BP_Core_User::get_users() is deprecated. |
130 | | if ( apply_filters( 'bp_use_legacy_user_query', false, __FUNCTION__, $r ) ) { |
| 129 | /** |
| 130 | * For legacy users. Use of BP_Core_User::get_users() is deprecated. |
| 131 | * |
| 132 | * Forcing this filter to true will use the legacy user query. As of |
| 133 | * BuddyPress 7.0.0, mirroring of the 'last_activity' value to usermeta |
| 134 | * is also disabled if true. See bp_update_user_last_activity(). |
| 135 | * |
| 136 | * @since 2.0.0 |
| 137 | * |
| 138 | * @param bool $retval Defaults to false. |
| 139 | * @param string $function Current function name. |
| 140 | * @param array $r User query arguments. |
| 141 | */ |
| 142 | $use_legacy_query = apply_filters( 'bp_use_legacy_user_query', false, __FUNCTION__, $r ); |
| 143 | |
| 144 | if ( $use_legacy_query ) { |
1073 | | // As of BuddyPress 2.0, last_activity is no longer stored in usermeta. |
1074 | | // However, we mirror it there for backward compatibility. Do not use! |
1075 | | // Remove our warning and re-add. |
1076 | | remove_filter( 'update_user_metadata', '_bp_update_user_meta_last_activity_warning', 10 ); |
1077 | | remove_filter( 'get_user_metadata', '_bp_get_user_meta_last_activity_warning', 10 ); |
1078 | | bp_update_user_meta( $user_id, 'last_activity', $time ); |
1079 | | add_filter( 'update_user_metadata', '_bp_update_user_meta_last_activity_warning', 10, 4 ); |
1080 | | add_filter( 'get_user_metadata', '_bp_get_user_meta_last_activity_warning', 10, 4 ); |
| 1089 | /** This filter is documented in bp_core_get_users() */ |
| 1090 | $use_legacy_query = apply_filters( 'bp_use_legacy_user_query', false, __FUNCTION__, [ 'user_id' => $user_id ] ); |
| 1091 | |
| 1092 | /* |
| 1093 | * As of BuddyPress 2.0, last_activity is no longer stored in usermeta. |
| 1094 | * However, we mirror it there for backward compatibility. Do not use! |
| 1095 | * |
| 1096 | * As of BuddyPress 7.0, mirroring is only allowed if the legacy user |
| 1097 | * query is enabled. |
| 1098 | */ |
| 1099 | if ( $use_legacy_query ) { |
| 1100 | remove_filter( 'update_user_metadata', '_bp_update_user_meta_last_activity_warning', 10 ); |
| 1101 | remove_filter( 'get_user_metadata', '_bp_get_user_meta_last_activity_warning', 10 ); |
| 1102 | bp_update_user_meta( $user_id, 'last_activity', $time ); |
| 1103 | add_filter( 'update_user_metadata', '_bp_update_user_meta_last_activity_warning', 10, 4 ); |
| 1104 | add_filter( 'get_user_metadata', '_bp_get_user_meta_last_activity_warning', 10, 4 ); |
| 1105 | } |