本文整理汇总了PHP中bp_update_user_meta函数的典型用法代码示例。如果您正苦于以下问题:PHP bp_update_user_meta函数的具体用法?PHP bp_update_user_meta怎么用?PHP bp_update_user_meta使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。
在下文中一共展示了bp_update_user_meta函数的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: bp_settings_update_notification_settings
/**
* Update email notification settings for a specific user.
*
* @since 2.3.5
*
* @param int $user_id ID of the user whose settings are being updated.
* @param array $settings Settings array.
*/
function bp_settings_update_notification_settings($user_id, $settings)
{
$user_id = (int) $user_id;
$settings = bp_settings_sanitize_notification_settings($settings);
foreach ($settings as $setting_key => $setting_value) {
bp_update_user_meta($user_id, $setting_key, $setting_value);
}
}
示例2: post_comment
/**
* Post a gallery or media Main comment on single page
*
* @return type
*/
public function post_comment()
{
// Bail if not a POST action
if ('POST' !== strtoupper($_SERVER['REQUEST_METHOD'])) {
return;
}
// Check the nonce
check_admin_referer('post_update', '_wpnonce_post_update');
if (!is_user_logged_in()) {
exit('-1');
}
$mpp_type = $_POST['mpp-type'];
$mpp_id = $_POST['mpp-id'];
if (empty($_POST['content'])) {
exit('-1<div id="message" class="error"><p>' . __('Please enter some content to post.', 'mediapress') . '</p></div>');
}
$activity_id = 0;
if (empty($_POST['object']) && bp_is_active('activity')) {
//we are preventing this comment to be set as the user's lastes_update
$user_id = bp_loggedin_user_id();
$old_latest_update = bp_get_user_meta($user_id, 'bp_latest_update', true);
$activity_id = bp_activity_post_update(array('content' => $_POST['content']));
//restore
if (!empty($old_latest_update)) {
bp_update_user_meta($user_id, 'bp_latest_update', $old_latest_update);
}
} elseif ($_POST['object'] == 'groups') {
if (!empty($_POST['item_id']) && bp_is_active('groups')) {
$activity_id = groups_post_update(array('content' => $_POST['content'], 'group_id' => $_POST['item_id']));
}
} else {
$activity_id = apply_filters('bp_activity_custom_update', $_POST['object'], $_POST['item_id'], $_POST['content']);
}
if (empty($activity_id)) {
exit('-1<div id="message" class="error"><p>' . __('There was a problem posting your update, please try again.', 'mediapress') . '</p></div>');
}
//if we have got activity id, let us add a meta key
if ($mpp_type == 'gallery') {
mpp_activity_update_gallery_id($activity_id, $mpp_id);
} elseif ($mpp_type == 'media') {
mpp_activity_update_media_id($activity_id, $mpp_id);
}
$activity = new BP_Activity_Activity($activity_id);
// $activity->component = buddypress()->mediapress->id;
$activity->type = 'mpp_media_upload';
$activity->save();
if (bp_has_activities('include=' . $activity_id)) {
while (bp_activities()) {
bp_the_activity();
mpp_locate_template(array('activity/entry.php'), true);
}
}
exit;
}
示例3: qa_buddypress_activity_post
function qa_buddypress_activity_post($args)
{
global $bp;
$defaults = array('content' => false, 'user_id' => $bp->loggedin_user->id);
$r = wp_parse_args($args, $defaults);
extract($r, EXTR_SKIP);
// Record this on the user's profile
$from_user_link = bp_core_get_userlink($user_id);
$activity_action = $action;
$activity_content = $content;
$primary_link = bp_core_get_userlink($user_id, false, true);
// Now write the values
$activity_id = bp_activity_add(array('user_id' => $user_id, 'action' => apply_filters('bp_activity_new_update_action', $activity_action), 'content' => apply_filters('bp_activity_new_update_content', $activity_content), 'primary_link' => apply_filters('bp_activity_new_update_primary_link', $primary_link), 'component' => $bp->activity->id, 'type' => $type));
// Add this update to the "latest update" usermeta so it can be fetched anywhere.
bp_update_user_meta($bp->loggedin_user->id, 'bp_latest_update', array('id' => $activity_id, 'content' => wp_filter_kses($content)));
do_action('bp_activity_posted_update', $content, $user_id, $activity_id);
return $activity_id;
}
示例4: total_friend_count
function total_friend_count($user_id = 0)
{
global $nxtdb, $bp;
if (!$user_id) {
$user_id = $bp->displayed_user->id ? $bp->displayed_user->id : $bp->loggedin_user->id;
}
/* This is stored in 'total_friend_count' usermeta.
This function will recalculate, update and return. */
$count = $nxtdb->get_var($nxtdb->prepare("SELECT COUNT(id) FROM {$bp->friends->table_name} WHERE (initiator_user_id = %d OR friend_user_id = %d) AND is_confirmed = 1", $user_id, $user_id));
// Do not update meta if user has never had friends
if (!$count && !bp_get_user_meta($user_id, 'total_friend_count', true)) {
return 0;
}
bp_update_user_meta($user_id, 'total_friend_count', (int) $count);
return (int) $count;
}
示例5: save
function save()
{
global $nxtdb, $bp;
$this->subject = apply_filters('messages_notice_subject_before_save', $this->subject, $this->id);
$this->message = apply_filters('messages_notice_message_before_save', $this->message, $this->id);
do_action_ref_array('messages_notice_before_save', array(&$this));
if (empty($this->id)) {
$sql = $nxtdb->prepare("INSERT INTO {$bp->messages->table_name_notices} (subject, message, date_sent, is_active) VALUES (%s, %s, %s, %d)", $this->subject, $this->message, $this->date_sent, $this->is_active);
} else {
$sql = $nxtdb->prepare("UPDATE {$bp->messages->table_name_notices} SET subject = %s, message = %s, is_active = %d WHERE id = %d", $this->subject, $this->message, $this->is_active, $this->id);
}
if (!$nxtdb->query($sql)) {
return false;
}
if (!($id = $this->id)) {
$id = $nxtdb->insert_id;
}
// Now deactivate all notices apart from the new one.
$nxtdb->query($nxtdb->prepare("UPDATE {$bp->messages->table_name_notices} SET is_active = 0 WHERE id != %d", $id));
bp_update_user_meta($bp->loggedin_user->id, 'last_activity', bp_core_current_time());
do_action_ref_array('messages_notice_after_save', array(&$this));
return true;
}
示例6: remove
function remove()
{
global $wpdb, $bp;
$sql = $wpdb->prepare("DELETE FROM {$bp->groups->table_name_members} WHERE user_id = %d AND group_id = %d", $this->user_id, $this->group_id);
if (!($result = $wpdb->query($sql))) {
return false;
}
groups_update_groupmeta($this->group_id, 'total_member_count', (int) groups_get_groupmeta($this->group_id, 'total_member_count') - 1);
$group_count = bp_get_user_meta($this->user_id, 'total_group_count', true);
if (!empty($group_count)) {
bp_update_user_meta($this->user_id, 'total_group_count', (int) $group_count - 1);
}
return $result;
}
示例7: bp_checkins_post_update
function bp_checkins_post_update($args = '')
{
global $bp;
$defaults = array('content' => false, 'user_id' => $bp->loggedin_user->id, 'type' => 'checkin', 'place_id' => false, 'place_name' => false, 'comment_id' => false, 'recorded_time' => bp_core_current_time());
$r = wp_parse_args($args, $defaults);
extract($r, EXTR_SKIP);
if ($type == "checkin" && (empty($content) || !strlen(trim($content)))) {
return false;
}
if (bp_is_user_spammer($user_id) || bp_is_user_deleted($user_id)) {
return false;
}
// Record this on the user's profile
$from_user_link = bp_core_get_userlink($user_id);
$component = 'checkins';
if ($type == 'checkin') {
$activity_action = sprintf(__('%s added a checkin', 'bp-checkins'), $from_user_link);
$activity_content = $content;
$primary_link = bp_core_get_userlink($user_id, false, true);
$checkin_type = 'activity_checkin';
$item_id = false;
$secondary_item_id = false;
} else {
if ($type == 'new_place' && !empty($place_id)) {
$component = 'places';
$place_permalink = '<a href="' . bp_get_checkins_places_the_permalink($place_id) . '" title="' . $place_name . '">' . $place_name . '</a>';
$activity_action = sprintf(__('%s added a new place %s', 'bp-checkins'), $from_user_link, $place_permalink);
$primary_link = bp_core_get_userlink($user_id, false, true);
$checkin_type = 'new_place';
$item_id = $place_id;
$activity_content = $content;
$secondary_item_id = false;
} else {
if ($type == 'place_checkin' && !empty($place_id)) {
$place_permalink = '<a href="' . bp_get_checkins_places_the_permalink($place_id) . '" title="' . $place_name . '">' . $place_name . '</a>';
$activity_action = sprintf(__('%s checked-in %s', 'bp-checkins'), $from_user_link, $place_permalink);
$primary_link = bp_core_get_userlink($user_id, false, true);
$checkin_type = 'place_checkin';
$item_id = $place_id;
$activity_content = false;
$secondary_item_id = false;
} else {
if ($type == 'place_comment' && !empty($place_id) && !empty($comment_id)) {
$component = 'places';
$place_permalink = '<a href="' . bp_get_checkins_places_the_permalink($place_id) . '" title="' . $place_name . '">' . $place_name . '</a>';
$activity_action = sprintf(__('%s added a comment on %s', 'bp-checkins'), $from_user_link, $place_permalink);
$primary_link = bp_core_get_userlink($user_id, false, true);
$checkin_type = 'place_comment';
$activity_content = $content;
$item_id = $place_id;
$secondary_item_id = $comment_id;
} else {
if ($type == 'place_checkin_comment' && !empty($place_id) && !empty($comment_id)) {
$component = 'places';
$place_permalink = '<a href="' . bp_get_checkins_places_the_permalink($place_id) . '" title="' . $place_name . '">' . $place_name . '</a>';
$activity_action = sprintf(__('%s checked-in and added a comment on %s', 'bp-checkins'), $from_user_link, $place_permalink);
$primary_link = bp_core_get_userlink($user_id, false, true);
$checkin_type = 'place_comment';
$activity_content = $content;
$item_id = $place_id;
$secondary_item_id = $comment_id;
}
}
}
}
}
// Now write the values
$activity_id = bp_activity_add(array('user_id' => $user_id, 'action' => apply_filters('bp_activity_new_update_action', $activity_action), 'content' => apply_filters('bp_activity_new_update_content', $activity_content), 'primary_link' => apply_filters('bp_activity_new_update_primary_link', $primary_link), 'component' => $component, 'type' => $checkin_type, 'item_id' => $item_id, 'secondary_item_id' => $secondary_item_id, 'recorded_time' => $recorded_time));
if ($type == 'checkin') {
bp_update_user_meta($bp->loggedin_user->id, 'bp_latest_update', array('id' => $activity_id, 'content' => wp_filter_kses($content)));
}
if ($checkin_type == 'place_comment') {
update_comment_meta($comment_id, 'group_place_activity_id', $activity_id);
}
do_action('bp_activity_posted_checkin', $content, $user_id, $activity_id);
return $activity_id;
}
示例8: prepare_buddypress_data
public static function prepare_buddypress_data($user_id, $config, $entry)
{
// required for user to display in the directory
if (function_exists('bp_update_user_last_activity')) {
bp_update_user_last_activity($user_id);
} else {
bp_update_user_meta($user_id, 'last_activity', true);
}
$buddypress_meta = rgars($config, 'meta/buddypress_meta');
if (empty($buddypress_meta)) {
return;
}
self::log_debug(__METHOD__ . '(): starting.');
$form = RGFormsModel::get_form_meta($entry['form_id']);
$buddypress_row = array();
$i = 0;
foreach ($buddypress_meta as $meta_item) {
if (empty($meta_item['meta_name']) || empty($meta_item['meta_value'])) {
continue;
}
$buddypress_row[$i]['field_id'] = $meta_item['meta_name'];
$buddypress_row[$i]['user_id'] = $user_id;
// get GF and BP fields
$gform_field = RGFormsModel::get_field($form, $meta_item['meta_value']);
if (version_compare(BP_VERSION, '1.6', '<')) {
$bp_field = new BP_XProfile_Field();
$bp_field->bp_xprofile_field($meta_item['meta_name']);
} else {
require_once WP_PLUGIN_DIR . '/buddypress/bp-xprofile/bp-xprofile-classes.php';
$bp_field = new BP_XProfile_Field($meta_item['meta_name']);
}
// if bp field is a checkbox AND gf field is a checkbox, get array of input values
$input_type = RGFormsModel::get_input_type($gform_field);
if (in_array($bp_field->type, array('checkbox', 'multiselectbox')) && in_array($input_type, array('checkbox', 'multiselect'))) {
$meta_value = RGFormsModel::get_lead_field_value($entry, $gform_field);
if (!is_array($meta_value)) {
$meta_value = explode(',', $meta_value);
}
$meta_value = self::maybe_get_category_name($gform_field, $meta_value);
$meta_value = array_filter($meta_value, 'GFUser::not_empty');
} else {
if ($bp_field->type == 'datebox' && $gform_field['type'] == 'date') {
if (version_compare(BP_VERSION, '2.1.1', '<')) {
$meta_value = strtotime(self::get_prepared_value($gform_field, $meta_item['meta_value'], $entry));
} else {
$meta_value = self::get_prepared_value($gform_field, $meta_item['meta_value'], $entry) . ' 00:00:00';
}
} else {
$meta_value = self::get_prepared_value($gform_field, $meta_item['meta_value'], $entry);
}
}
self::log_debug(__METHOD__ . "(): Meta item: {$meta_item['meta_name']}. Value: {$meta_value}");
$buddypress_row[$i]['value'] = $meta_value;
$buddypress_row[$i]['last_update'] = date('Y-m-d H:i:s');
$buddypress_row[$i]['field'] = $bp_field;
$i++;
}
GFUserData::insert_buddypress_data($buddypress_row);
self::log_debug(__METHOD__ . '(): finished.');
}
示例9: xprofile_sync_wp_profile
/**
* Syncs Xprofile data to the standard built in WordPress profile data.
*
* @package BuddyPress Core
*/
function xprofile_sync_wp_profile($user_id = 0)
{
// Bail if profile syncing is disabled
if (bp_disable_profile_sync()) {
return true;
}
if (empty($user_id)) {
$user_id = bp_loggedin_user_id();
}
if (empty($user_id)) {
return false;
}
$fullname = xprofile_get_field_data(bp_xprofile_fullname_field_id(), $user_id);
$space = strpos($fullname, ' ');
if (false === $space) {
$firstname = $fullname;
$lastname = '';
} else {
$firstname = substr($fullname, 0, $space);
$lastname = trim(substr($fullname, $space, strlen($fullname)));
}
bp_update_user_meta($user_id, 'nickname', $fullname);
bp_update_user_meta($user_id, 'first_name', $firstname);
bp_update_user_meta($user_id, 'last_name', $lastname);
global $wpdb;
$wpdb->query($wpdb->prepare("UPDATE {$wpdb->users} SET display_name = %s WHERE ID = %d", $fullname, $user_id));
}
示例10: bp_core_signup_user
/**
* Process data submitted at user registration and convert to a signup object.
*
* @since 1.2.0
*
* @todo There appears to be a bug in the return value on success.
*
* @param string $user_login Login name requested by the user.
* @param string $user_password Password requested by the user.
* @param string $user_email Email address entered by the user.
* @param array $usermeta Miscellaneous metadata about the user (blog-specific
* signup data, xprofile data, etc).
* @return bool|WP_Error True on success, WP_Error on failure.
*/
function bp_core_signup_user($user_login, $user_password, $user_email, $usermeta)
{
$bp = buddypress();
// We need to cast $user_id to pass to the filters.
$user_id = false;
// Multisite installs have their own install procedure.
if (is_multisite()) {
wpmu_signup_user($user_login, $user_email, $usermeta);
} else {
// Format data.
$user_login = preg_replace('/\\s+/', '', sanitize_user($user_login, true));
$user_email = sanitize_email($user_email);
$activation_key = wp_generate_password(32, false);
/**
* WordPress's default behavior is to create user accounts
* immediately at registration time. BuddyPress uses a system
* borrowed from WordPress Multisite, where signups are stored
* separately and accounts are only created at the time of
* activation. For backward compatibility with plugins that may
* be anticipating WP's default behavior, BP silently creates
* accounts for registrations (though it does not use them). If
* you know that you are not running any plugins dependent on
* these pending accounts, you may want to save a little DB
* clutter by defining setting the BP_SIGNUPS_SKIP_USER_CREATION
* to true in your wp-config.php file.
*/
if (!defined('BP_SIGNUPS_SKIP_USER_CREATION') || !BP_SIGNUPS_SKIP_USER_CREATION) {
$user_id = BP_Signup::add_backcompat($user_login, $user_password, $user_email, $usermeta);
if (is_wp_error($user_id)) {
return $user_id;
}
bp_update_user_meta($user_id, 'activation_key', $activation_key);
}
$args = array('user_login' => $user_login, 'user_email' => $user_email, 'activation_key' => $activation_key, 'meta' => $usermeta);
BP_Signup::add($args);
/**
* Filters if BuddyPress should send an activation key for a new signup.
*
* @since 1.2.3
*
* @param bool $value Whether or not to send the activation key.
* @param int $user_id User ID to send activation key to.
* @param string $user_email User email to send activation key to.
* @param string $activation_key Activation key to be sent.
* @param array $usermeta Miscellaneous metadata about the user (blog-specific
* signup data, xprofile data, etc).
*/
if (apply_filters('bp_core_signup_send_activation_key', true, $user_id, $user_email, $activation_key, $usermeta)) {
bp_core_signup_send_validation_email($user_id, $user_email, $activation_key, $user_login);
}
}
$bp->signup->username = $user_login;
/**
* Fires at the end of the process to sign up a user.
*
* @since 1.2.2
*
* @param bool|WP_Error $user_id True on success, WP_Error on failure.
* @param string $user_login Login name requested by the user.
* @param string $user_password Password requested by the user.
* @param string $user_email Email address requested by the user.
* @param array $usermeta Miscellaneous metadata about the user (blog-specific
* signup data, xprofile data, etc).
*/
do_action('bp_core_signup_user', $user_id, $user_login, $user_password, $user_email, $usermeta);
return $user_id;
}
示例11: update_meta
function update_meta($args = '')
{
$defaults = array('id' => 0, 'meta_key' => null, 'meta_value' => null, 'meta_table' => 'usermeta', 'meta_field' => 'user_id', 'cache_group' => 'users');
$args = wp_parse_args($args, $defaults);
extract($args, EXTR_SKIP);
return bp_update_user_meta($id, $meta_key, $meta_value);
}
示例12: refresh_total_group_count_for_user
/**
* Refresh the total_group_count for a user.
*
* @since BuddyPress (1.8.0)
*
* @param int $user_id ID of the user.
*
* @return bool True on success, false on failure.
*/
public static function refresh_total_group_count_for_user($user_id)
{
return bp_update_user_meta($user_id, 'total_group_count', (int) self::total_group_count($user_id));
}
示例13: test_bp_user_query_with_user_meta_argument
/**
* @group meta
* @group BP5904
*/
public function test_bp_user_query_with_user_meta_argument()
{
$u1 = $this->factory->user->create();
$u2 = $this->factory->user->create();
bp_update_user_meta($u2, 'foo', 'bar');
$q = new BP_User_Query(array('meta_key' => 'foo', 'meta_value' => 'bar'));
$found_user_ids = array_values(wp_parse_id_list(wp_list_pluck($q->results, 'ID')));
// Do a assertNotContains because there are weird issues with user #1 as created by WP
$this->assertNotContains($u1, $found_user_ids);
$this->assertEquals(array($u2), $found_user_ids);
}
示例14: bp_activity_post_update
/**
* Post an activity update
*
* @since 1.2.0
*
* @param array $args See docs for $defaults for details
*
* @global object $bp BuddyPress global settings
* @uses nxt_parse_args()
* @uses bp_core_is_user_spammer()
* @uses bp_core_is_user_deleted()
* @uses bp_core_get_userlink()
* @uses bp_activity_add()
* @uses apply_filters() To call the 'bp_activity_new_update_action' hook
* @uses apply_filters() To call the 'bp_activity_new_update_content' hook
* @uses apply_filters() To call the 'bp_activity_new_update_primary_link' hook
* @uses bp_update_user_meta()
* @uses nxt_filter_kses()
* @uses do_action() To call the 'bp_activity_posted_update' hook
*
* @return int $activity_id The activity id
*/
function bp_activity_post_update($args = '')
{
global $bp;
$defaults = array('content' => false, 'user_id' => $bp->loggedin_user->id);
$r = nxt_parse_args($args, $defaults);
extract($r, EXTR_SKIP);
if (empty($content) || !strlen(trim($content))) {
return false;
}
if (bp_core_is_user_spammer($user_id) || bp_core_is_user_deleted($user_id)) {
return false;
}
// Record this on the user's profile
$from_user_link = bp_core_get_userlink($user_id);
$activity_action = sprintf(__('%s posted an update', 'buddypress'), $from_user_link);
$activity_content = $content;
$primary_link = bp_core_get_userlink($user_id, false, true);
// Now write the values
$activity_id = bp_activity_add(array('user_id' => $user_id, 'action' => apply_filters('bp_activity_new_update_action', $activity_action), 'content' => apply_filters('bp_activity_new_update_content', $activity_content), 'primary_link' => apply_filters('bp_activity_new_update_primary_link', $primary_link), 'component' => $bp->activity->id, 'type' => 'activity_update'));
// Add this update to the "latest update" usermeta so it can be fetched anywhere.
bp_update_user_meta($bp->loggedin_user->id, 'bp_latest_update', array('id' => $activity_id, 'content' => nxt_filter_kses($content)));
do_action('bp_activity_posted_update', $content, $user_id, $activity_id);
return $activity_id;
}
示例15: delete_media
function delete_media(){
global $bp_media_count;
bp_media_init_count($this->owner);
switch ($this->type) {
case 'image':
$bp_media_count['images'] = intval($bp_media_count['images']) - 1;
break;
case 'video':
$bp_media_count['videos'] = intval($bp_media_count['videos']) - 1;
break;
case 'audio':
$bp_media_count['audio'] = intval($bp_media_count['audio']) - 1;
break;
}
wp_delete_attachment($this->attachment_id);
// $activity_id = get_post_meta($post_id, 'bp_media_child_activity', true);
// if($activity_id)
// bp_activity_delete_by_activity_id($activity_id);
wp_delete_post($this->id);
bp_update_user_meta($this->owner, 'bp_media_count', $bp_media_count);
}