_bp_get_user_meta_last_activity_warning( null $retval, int $object_id, string $meta_key, bool $single )
Backward compatibility for ‘last_activity’ usermeta fetching.
Description Description
In BuddyPress 2.0, user last_activity data was moved out of usermeta. For backward compatibility, we continue to mirror the data there. This function serves two purposes: it warns plugin authors of the change, and it returns the data from the proper location.
Parameters Parameters
- $retval
-
(Required) Null retval value.
- $object_id
-
(Required) ID of the user.
- $meta_key
-
(Required) Meta key being fetched.
- $single
-
(Required) Whether a single key is being fetched (vs an array).
Return Return
(string|null)
Source Source
File: bp-members/bp-members-functions.php
function _bp_get_user_meta_last_activity_warning( $retval, $object_id, $meta_key, $single ) {
static $warned = false;
if ( 'last_activity' === $meta_key ) {
// Don't send the warning more than once per pageload.
if ( false === $warned ) {
_doing_it_wrong( 'get_user_meta( $user_id, \'last_activity\' )', __( 'User last_activity data is no longer stored in usermeta. Use bp_get_user_last_activity() instead.', 'buddypress' ), '2.0.0' );
$warned = true;
}
$user_last_activity = bp_get_user_last_activity( $object_id );
if ( $single ) {
return $user_last_activity;
} else {
return array( $user_last_activity );
}
}
return $retval;
}
Changelog Changelog
| Version | Description |
|---|---|
| 2.9.3 | Added the $single parameter. |
| 2.0.0 | Introduced. |