本文整理汇总了PHP中update_user_meta函数的典型用法代码示例。如果您正苦于以下问题:PHP update_user_meta函数的具体用法?PHP update_user_meta怎么用?PHP update_user_meta使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。
在下文中一共展示了update_user_meta函数的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: wpmudev_chat_settings_screen_chat_proc
function wpmudev_chat_settings_screen_chat_proc()
{
global $wpmudev_chat, $current_user, $bp;
if (isset($_POST['wpmudev_chat_user_settings'])) {
//echo "_POST<pre>"; print_r($_POST); echo "</pre>";
//die();
if (isset($_POST['wpmudev_chat_user_settings']['chat_user_status'])) {
$chat_user_status = esc_attr($_POST['wpmudev_chat_user_settings']['chat_user_status']);
if (isset($wpmudev_chat->_chat_options['user-statuses'][$chat_user_status])) {
wpmudev_chat_update_user_status($bp->displayed_user->id, $chat_user_status);
}
unset($_POST['wpmudev_chat_user_settings']['chat_user_status']);
}
$user_meta = get_user_meta($bp->displayed_user->id, 'wpmudev-chat-user', true);
if (!$user_meta) {
$user_meta = array();
}
$user_meta = wp_parse_args($_POST['wpmudev_chat_user_settings'], $user_meta);
update_user_meta($bp->displayed_user->id, 'wpmudev-chat-user', $user_meta);
$wpmudev_chat->user_meta = $user_meta;
// Show the standard BP green success message
bp_core_add_message(__('Changes saved.', $wpmudev_chat->translation_domain));
}
add_action('bp_template_title', 'wpmudev_chat_settings_show_screen_title');
add_action('bp_template_content', 'wpmudev_chat_settings_show_screen_content');
bp_core_load_template(apply_filters('bp_core_template_plugin', 'members/single/plugins'));
return;
}
示例2: hide
/**
* When the user decides to not have this show again save user meta to make it so.
*
* @param array $data Sanitized data to use for saving.
*
* @returns bool Always returns true
*/
public function hide($data)
{
$user_id = get_current_user_ID();
update_user_meta($user_id, 'lasso_hide_tour', true);
do_action('lasso_tour_hidden', $user_id);
return true;
}
示例3: restrict_save_data
function restrict_save_data($user_id)
{
if (!current_user_can('add_users')) {
return false;
}
update_user_meta($user_id, '_access', $_POST['allow']);
}
开发者ID:sholex,项目名称:-Wordpress-Restrict-Author-Posting-by-Custom-Taxonomy,代码行数:7,代码来源:Restrict+Author+Posting.php
示例4: upmeta
function upmeta($i)
{
if (is_user_logged_in()) {
global $f;
update_user_meta($f, 'like-posts', serialize($i));
}
}
示例5: tie_like_post
function tie_like_post()
{
global $user_ID;
$postID = $_REQUEST['post'];
if (is_numeric($postID)) {
$count = get_post_meta($postID, 'tie_likes', true);
if (empty($count) || $count == '') {
$count = 0;
}
$count++;
if ($user_ID) {
$user_liked = get_the_author_meta('liked', $user_ID);
$user_liked_posts = explode(',', $user_liked);
if (empty($user_liked)) {
update_user_meta($user_ID, 'liked', $postID);
update_post_meta($postID, 'tie_likes', $count);
} else {
if (!in_array($postID, $user_liked_posts)) {
update_post_meta($postID, 'tie_likes', $count);
$postID = $user_liked . ',' . $postID;
update_user_meta($user_ID, 'liked', $postID);
}
}
} else {
$user_liked = $_COOKIE["tie_likes_" . $postID];
if (empty($user_liked)) {
setcookie('tie_likes_' . $postID, $postID, time() + 7776000, '/');
update_post_meta($postID, 'tie_likes', $count);
}
}
echo $count;
}
die;
}
示例6: usersExist
/**
* @Given /^Users exist:$/
*/
public function usersExist(TableNode $table)
{
$usersData = $table->getHash();
add_filter('send_password_change_email', '__return_false');
add_filter('send_email_change_email', '__return_false');
foreach ($usersData as $userData) {
if (empty($userData['login'])) {
throw new \InvalidArgumentException('You must provide a user login!');
}
$user = get_user_by('login', $userData['login']);
$data = $this->getUserDataFromTable($userData);
if ($user) {
$data['ID'] = $user->ID;
}
$result = $user ? wp_update_user($data) : wp_insert_user($data);
if (is_wp_error($result)) {
throw new \UnexpectedValueException('User could not be created: ' . $result->get_error_message());
}
foreach ($this->getUserMetaDataFromTable($userData) as $key => $value) {
update_user_meta($user->ID, $key, $value);
}
}
remove_filter('send_password_change_email', '__return_false');
remove_filter('send_email_change_email', '__return_false');
}
示例7: jr_handle_resume_subscriptions_ipn
function jr_handle_resume_subscriptions_ipn($posted)
{
global $jr_log;
$jr_log->write_log('Valid IPN response detected: ' . print_r($posted, true));
// Custom holds post ID
if (!empty($posted['txn_type']) && !empty($posted['custom']) && is_numeric($posted['custom']) && $posted['custom'] > 0) {
$user_id = (int) $posted['custom'];
switch (strtolower($posted['txn_type'])) {
case "subscr_signup":
update_user_meta($user_id, '_valid_resume_subscription', '1');
do_action('user_resume_subscription_started', $user_id);
exit;
break;
case "subscr_payment":
exit;
break;
case "subscr_cancel":
case "subscr_failed":
case "subscr_eot":
update_user_meta($user_id, '_valid_resume_subscription', '0');
do_action('user_resume_subscription_ended', $user_id);
exit;
break;
}
}
}
示例8: update_user_meta_values
function update_user_meta_values($my_id = '', $metakey = '', $metavalue = '')
{
global $bp;
$my_id = $bp->displayed_user->id;
$update_user_meta_values = update_user_meta($my_id, $metakey, $metavalue);
return $get_user_meta_values;
}
示例9: memberful_private_rss_feed_link
/**
* @param string $success_message - '', if present, will return an clickable link
* @param string $error_message - "You don’t have access to this RSS feed."
* @param bool $return
* @return string
*/
function memberful_private_rss_feed_link($success_message = '', $error_message = "You don’t have access to this RSS feed.", $return = false)
{
$error_message = apply_filters('memberful_private_rss_feed_error_message', $error_message);
if (!is_user_logged_in()) {
return memberful_private_rss_feed_link_response_helper($error_message, $return);
}
$requiredPlan = memberful_private_user_feed_settings_get_required_plan();
// We want to allow the private user feed only if the admin has configured it.
if ($requiredPlan == false) {
return memberful_private_rss_feed_link_response_helper($error_message, $return);
}
$current_user_id = get_current_user_id();
if (!is_subscribed_to_memberful_plan($requiredPlan, $current_user_id)) {
return memberful_private_rss_feed_link_response_helper($error_message, $return);
}
$feedToken = get_user_meta($current_user_id, 'memberful_private_user_feed_token', true);
if ($feedToken == false || $feedToken == '') {
$feedToken = substr(md5(uniqid(rand(1, 10000))), 2, 30);
update_user_meta($current_user_id, 'memberful_private_user_feed_token', $feedToken);
}
$link = get_home_url() . '/' . memberful_private_user_feed_get_url_identifier($feedToken);
if ($success_message != '') {
$link = '<a href="' . $link . '">' . do_shortcode($success_message) . '</a>';
}
return memberful_private_rss_feed_link_response_helper($link, $return);
}
示例10: save_profile_admin
/**
*
* @TODO document
*
*/
function save_profile_admin($user_ID)
{
if (!isset($this->tabs) || empty($this->tabs)) {
return;
}
// Loop through tabs
foreach ($this->tabs as $tab => $t) {
// Loop through tab options
foreach ($t->options as $oid => $o) {
// Note: If the value is null, then test to see if the option is already set to something
// create and overwrite the option to null in that case (i.e. it is being set to empty)
if (isset($o['selectvalues']) && pagelines_is_multi_option($oid, $o)) {
foreach ($o['selectvalues'] as $sid => $s) {
$option_value = isset($_POST[$sid]) ? $_POST[$sid] : null;
if (!empty($option_value) || pl_um($sid, $user_ID)) {
update_post_meta($user_ID, $sid, $option_value);
}
}
} else {
$option_value = isset($_POST[$oid]) ? $_POST[$oid] : null;
if (!empty($option_value) || pl_um($oid, $user_ID)) {
update_user_meta($user_ID, $oid, $option_value);
}
}
}
}
}
示例11: __construct
function __construct($par = null)
{
$this->par = $par;
/* excel */
if ($_GET['action'] == 'xls') {
$this->excel = true;
}
/* search query */
if ($_GET['src']) {
$this->search_query = $_GET['src'];
}
/* filter by month */
if ($_GET['mth'] && $_GET['yr']) {
$this->mth = $_GET['mth'];
$this->yr = $_GET['yr'];
}
/* determine max row per page */
if ($_GET['max'] > 0) {
$this->set_max($_GET['max']);
update_user_meta(get_current_user_id(), get_query_var('pagename') . '_max', $_GET['max']);
} else {
$val = (int) get_user_meta(get_current_user_id(), get_query_var('pagename') . '_max', true);
if ($val > 0) {
$this->set_max($val);
}
}
/* mysql limit start, max */
$this->paged = $_GET['paged'] ? $_GET['paged'] - 1 : 0;
$this->start = $this->paged * $this->get_max();
if (method_exists($this, 'query')) {
$this->data = $this->query();
wp_enqueue_script('list-table');
}
}
示例12: qq_oauth
function qq_oauth()
{
$code = $_GET['code'];
$token_url = "https://graph.qq.com/oauth2.0/token?client_id=" . QQ_APPID . "&client_secret=" . QQ_APPSECRET . "&grant_type=authorization_code&redirect_uri=" . urlencode(home_url()) . "&code=" . $code;
$response = wp_remote_get($token_url);
$response = $response['body'];
if (strpos($response, "callback") !== false) {
wp_redirect(home_url());
}
$params = array();
parse_str($response, $params);
$qq_access_token = $params["access_token"];
$graph_url = "https://graph.qq.com/oauth2.0/me?access_token=" . $qq_access_token;
$str = wp_remote_get($graph_url);
$str = $str['body'];
if (strpos($str, "callback") !== false) {
$lpos = strpos($str, "(");
$rpos = strrpos($str, ")");
$str = substr($str, $lpos + 1, $rpos - $lpos - 1);
}
$user = json_decode($str, true);
if (isset($user->error)) {
echo "<h3>错误代码:</h3>" . $user->error;
echo "<h3>信息 :</h3>" . $user->error_description;
exit;
}
$qq_openid = $user['openid'];
if (!$qq_openid) {
wp_redirect(home_url());
exit;
}
$get_user_info = "https://graph.qq.com/user/get_user_info?" . "access_token=" . $qq_access_token . "&oauth_consumer_key=" . QQ_APPID . "&openid=" . $qq_openid . "&format=json";
$data = wp_remote_get($get_user_info);
$data = $data['body'];
$data = json_decode($data, true);
$username = $data['nickname'];
$avatar = $data['figureurl_2'];
if (is_user_logged_in()) {
$this_user = wp_get_current_user();
update_user_meta($this_user->ID, "qq_openid", $qq_openid);
update_user_meta($this_user->ID, "qq_avatar", $avatar);
fa_qq_oauth_redirect();
} else {
$user_qq = get_users(array("meta_key " => "qq_openid", "meta_value" => $qq_openid));
if (is_wp_error($user_qq) || !count($user_qq)) {
$login_name = wp_create_nonce($qq_openid);
$random_password = wp_generate_password($length = 12, $include_standard_special_chars = false);
$userdata = array('user_login' => $login_name, 'display_name' => $username, 'user_pass' => $random_password, 'nick_name' => $username);
$user_id = wp_insert_user($userdata);
wp_signon(array("user_login" => $login_name, "user_password" => $random_password), false);
update_user_meta($user_id, "qq_openid", $qq_openid);
update_user_meta($user_id, "qq_avatar", $avatar);
fa_qq_oauth_redirect();
} else {
wp_set_auth_cookie($user_qq[0]->ID);
update_user_meta($user_qq[0]->ID, "qq_avatar", $avatar);
fa_qq_oauth_redirect();
}
}
}
示例13: tt_save_custom_user_profile_fields
function tt_save_custom_user_profile_fields($user_id)
{
if (!current_user_can('edit_user', $user_id)) {
return FALSE;
}
update_user_meta($user_id, 'enable_auto_publish', isset($_POST['enable_auto_publish']) ? $_POST['enable_auto_publish'] : 'false');
}
示例14: um_admin_addon_hook
function um_admin_addon_hook($hook)
{
global $ultimatemember;
switch ($hook) {
case 'bp_avatar_transfer':
if (class_exists('BuddyPress')) {
$path = bp_core_avatar_upload_path() . '/avatars';
$files = glob($path . '/*');
$i = 0;
foreach ($files as $key) {
$q = count(glob("{$key}/*")) === 0 ? 0 : 1;
if ($q == 1) {
$photo = glob($key . '/*');
foreach ($photo as $file) {
if (strstr($file, 'bpfull')) {
$get_user_id = explode('/', $file);
array_pop($get_user_id);
$user_id = end($get_user_id);
if (!file_exists($ultimatemember->files->upload_basedir . $user_id . '/profile_photo.jpg')) {
$ultimatemember->files->new_user($user_id);
copy($file, $ultimatemember->files->upload_basedir . $user_id . '/profile_photo.jpg');
update_user_meta($user_id, 'profile_photo', 'profile_photo.jpg');
$i++;
}
}
}
}
}
$this->content = '<p><strong>Done. Process completed!</p>';
$this->content .= $i . ' user(s) changed.</strong></p>';
}
break;
}
}
示例15: wpas_upgrade_321
/**
* Upgrade routine for 3.2.1
*
* @since 3.2.1
* @return void
*/
function wpas_upgrade_321()
{
$agents = wpas_list_users('edit_ticket');
foreach ($agents as $agent_id => $agent_name) {
update_user_meta($agent_id, 'wpas_can_be_assigned', 'yes');
}
}