Changeset 4372 for trunk/bp-core/bp-core-functions.php
- Timestamp:
- 05/16/2011 08:54:02 PM (14 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/bp-core/bp-core-functions.php
r4344 r4372 642 642 return false; 643 643 644 $activity = get_user_meta( $bp->loggedin_user->id, 'last_activity', true );644 $activity = get_user_meta( $bp->loggedin_user->id, bp_get_user_meta_key( 'last_activity' ), true ); 645 645 646 646 if ( !is_numeric( $activity ) ) … … 651 651 652 652 if ( empty( $activity ) || strtotime( $current_time ) >= strtotime( '+5 minutes', $activity ) ) 653 update_user_meta( $bp->loggedin_user->id, 'last_activity', $current_time );653 update_user_meta( $bp->loggedin_user->id, bp_get_user_meta_key( 'last_activity' ), $current_time ); 654 654 } 655 655 add_action( 'wp_head', 'bp_core_record_activity' ); … … 996 996 } 997 997 998 /** 999 * Get the meta_key for a given piece of user metadata 1000 * 1001 * BuddyPress stores a number of pieces of userdata in the WordPress central usermeta table. In 1002 * order to allow plugins to enable multiple instances of BuddyPress on a single WP installation, 1003 * BP's usermeta keys are abstracted and stored in the $bp global, at $bp->user_meta_keys. 1004 * 1005 * Plugin authors who access or modify metadata created by BuddyPress should use 1006 * this function exclusively in the context of the _user_meta() functions. For example, 1007 * $last_active = get_user_meta( $user_id, bp_get_user_meta_key( 'last_activity' ), true ); 1008 * Do not hardcode these keys. 1009 * 1010 * If your plugin introduces custom user metadata that might change between multiple BP instances 1011 * on a single WP installation, you are strongly recommended to register your meta keys in the $bp 1012 * global (see BP_Core_Component::setup_globals()), and use this function when storing and 1013 * retrieving metadata. 1014 * 1015 * @package BuddyPress 1016 * @since 1.3 1017 * @see BP_Core_Component::_setup_globals() 1018 * 1019 * @uses apply_filters() Filter bp_get_user_meta_key to modify keys individually 1020 * @param str $name 1021 * @return str $key 1022 */ 1023 function bp_get_user_meta_key( $name = false ) { 1024 global $bp; 1025 1026 if ( !$name ) 1027 return false; 1028 1029 $key = isset( $bp->user_meta_keys->$name ) ? $bp->user_meta_keys->$name : false; 1030 1031 return apply_filters( 'bp_get_user_meta_key', $key, $name ); 1032 } 1033 998 1034 /** Global Manipulators *******************************************************/ 999 1035
Note: See TracChangeset
for help on using the changeset viewer.