1002 | | // As of BuddyPress 2.0, last_activity is no longer stored in usermeta. |
1003 | | // However, we mirror it there for backward compatibility. Do not use! |
1004 | | // Remove our warning and re-add. |
1005 | | remove_filter( 'update_user_metadata', '_bp_update_user_meta_last_activity_warning', 10 ); |
1006 | | remove_filter( 'get_user_metadata', '_bp_get_user_meta_last_activity_warning', 10 ); |
1007 | | bp_update_user_meta( $user_id, 'last_activity', $time ); |
1008 | | add_filter( 'update_user_metadata', '_bp_update_user_meta_last_activity_warning', 10, 4 ); |
1009 | | add_filter( 'get_user_metadata', '_bp_get_user_meta_last_activity_warning', 10, 4 ); |
| 1002 | /** |
| 1003 | * Filters whether the legacy mirroring of last_activity to usermeta should be disabled. |
| 1004 | * |
| 1005 | * User last_activity data was moved to the activity tables in BuddyPress 2.0, but |
| 1006 | * continued to be mirrored to usermeta for backward compatiblity. In BuddyPress 4.0, |
| 1007 | * this mirroring was disabled by default. |
| 1008 | * |
| 1009 | * @since 4.0.0 |
| 1010 | * |
| 1011 | * @param bool $enable True to enable legacy usermeta mirroring. Default false. |
| 1012 | */ |
| 1013 | if ( apply_filters( 'bp_mirror_user_last_activity_to_usermeta', false ) ) { |
| 1014 | // Remove our warning and re-add. |
| 1015 | remove_filter( 'update_user_metadata', '_bp_update_user_meta_last_activity_warning', 10 ); |
| 1016 | remove_filter( 'get_user_metadata', '_bp_get_user_meta_last_activity_warning', 10 ); |
| 1017 | bp_update_user_meta( $user_id, 'last_activity', $time ); |
| 1018 | add_filter( 'update_user_metadata', '_bp_update_user_meta_last_activity_warning', 10, 4 ); |
| 1019 | add_filter( 'get_user_metadata', '_bp_get_user_meta_last_activity_warning', 10, 4 ); |
| 1020 | } |