Changeset 4558 for trunk/bp-core/bp-core-functions.php
- Timestamp:
- 06/24/2011 06:52:57 PM (14 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/bp-core/bp-core-functions.php
r4556 r4558 656 656 * @package BuddyPress Core 657 657 * @global $userdata WordPress user data for the current logged in user. 658 * @uses update_user_meta() WordPressfunction to update user metadata in the usermeta table.658 * @uses bp_update_user_meta() BP function to update user metadata in the usermeta table. 659 659 */ 660 660 function bp_core_record_activity() { … … 664 664 return false; 665 665 666 $activity = get_user_meta( $bp->loggedin_user->id, bp_get_user_meta_key( 'last_activity' ), true );666 $activity = bp_get_user_meta( $bp->loggedin_user->id, 'last_activity', true ); 667 667 668 668 if ( !is_numeric( $activity ) ) … … 673 673 674 674 if ( empty( $activity ) || strtotime( $current_time ) >= strtotime( '+5 minutes', $activity ) ) 675 update_user_meta( $bp->loggedin_user->id, bp_get_user_meta_key( 'last_activity' ), $current_time );675 bp_update_user_meta( $bp->loggedin_user->id, 'last_activity', $current_time ); 676 676 } 677 677 add_action( 'wp_head', 'bp_core_record_activity' ); … … 1025 1025 * BP's usermeta keys are filtered with this function, so that they can be altered on the fly. 1026 1026 * 1027 * Plugin authors who access or modify metadata created by BuddyPress should use 1028 * this function exclusively in the context of the _user_meta() functions. For example, 1027 * Plugin authors should use BP's _user_meta() functions, which bakes in bp_get_user_meta_key(). 1028 * $last_active = bp_get_user_meta( $user_id, 'last_activity', true ); 1029 * If you have to use WP's _user_meta() functions for some reason, you should use this function, eg 1029 1030 * $last_active = get_user_meta( $user_id, bp_get_user_meta_key( 'last_activity' ), true ); 1030 * Do not hardcode these keys. 1031 * 1032 * If your plugin introduces custom user metadata that might change between multiple BP instances 1033 * on a single WP installation, you are strongly recommended to use this function when storing and 1034 * retrieving metadata. 1031 * If using the WP functions, do not not hardcode your meta keys. 1035 1032 * 1036 1033 * @package BuddyPress … … 1044 1041 return apply_filters( 'bp_get_user_meta_key', $key ); 1045 1042 } 1043 1044 /** 1045 * Get a piece of usermeta 1046 * 1047 * This is a wrapper for get_user_meta() that allows for easy use of bp_get_user_meta_key(), thereby 1048 * increasing compatibility with non-standard BP setups. 1049 * 1050 * @package BuddyPress 1051 * @since 1.3 1052 * 1053 * @uses bp_get_user_meta_key() For a filterable version of the meta key 1054 * @uses get_user_meta() See get_user_meta() docs for more details on parameters 1055 * @param int $user_id The id of the user whose meta you're fetching 1056 * @param string $key The meta key to retrieve. 1057 * @param bool $single Whether to return a single value. 1058 * @return mixed Will be an array if $single is false. Will be value of meta data field if $single 1059 * is true. 1060 */ 1061 function bp_get_user_meta( $user_id, $key, $single = false ) { 1062 return get_user_meta( $user_id, bp_get_user_meta_key( $key ), $single ); 1063 } 1064 1065 /** 1066 * Update a piece of usermeta 1067 * 1068 * This is a wrapper for update_user_meta() that allows for easy use of bp_get_user_meta_key(), 1069 * thereby increasing compatibility with non-standard BP setups. 1070 * 1071 * @package BuddyPress 1072 * @since 1.3 1073 * 1074 * @uses bp_get_user_meta_key() For a filterable version of the meta key 1075 * @uses update_user_meta() See update_user_meta() docs for more details on parameters 1076 * @param int $user_id The id of the user whose meta you're setting 1077 * @param string $key The meta key to set. 1078 * @param mixed $value Metadata value. 1079 * @param mixed $prev_value Optional. Previous value to check before removing. 1080 * @return bool False on failure, true if success. 1081 */ 1082 function bp_update_user_meta( $user_id, $key, $value, $prev_value = '' ) { 1083 return update_user_meta( $user_id, bp_get_user_meta_key( $key ), $value, $prev_value ); 1084 } 1085 1086 /** 1087 * Delete a piece of usermeta 1088 * 1089 * This is a wrapper for delete_user_meta() that allows for easy use of bp_get_user_meta_key(), 1090 * thereby increasing compatibility with non-standard BP setups. 1091 * 1092 * @package BuddyPress 1093 * @since 1.3 1094 * 1095 * @uses bp_get_user_meta_key() For a filterable version of the meta key 1096 * @uses delete_user_meta() See delete_user_meta() docs for more details on parameters 1097 * @param int $user_id The id of the user whose meta you're deleting 1098 * @param string $key The meta key to delete. 1099 * @param mixed $value Optional. Metadata value. 1100 * @return bool False for failure. True for success. 1101 */ 1102 function bp_delete_user_meta( $user_id, $key, $value = '' ) { 1103 return delete_user_meta( $user_id, bp_get_user_meta_key( $key ), $value ); 1104 } 1105 1046 1106 1047 1107 /** Global Manipulators *******************************************************/
Note: See TracChangeset
for help on using the changeset viewer.