本文整理汇总了PHP中add_user_meta函数的典型用法代码示例。如果您正苦于以下问题:PHP add_user_meta函数的具体用法?PHP add_user_meta怎么用?PHP add_user_meta使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。
在下文中一共展示了add_user_meta函数的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: hide_welcome_callback
/**
* Hide the Settings welcome on click
*
* Sets a user meta key that once set
*/
public function hide_welcome_callback()
{
global $current_user;
$user_id = $current_user->ID;
add_user_meta($user_id, 'gmb_hide_pro_welcome', 'true', true);
wp_die();
// ajax call must die to avoid trailing 0 in your response
}
示例2: doSign
public function doSign()
{
$offset = get_option('gmt_offset') * HOUR_IN_SECONDS;
$dayid = floor((time() + $offset) / DAY_IN_SECONDS);
$uid = get_current_user_id();
$lastSign = get_user_meta($uid, 'last_sign_at', true);
if ($lastSign && $lastSign >= $dayid) {
return new WP_Error('signed', '当日已签到过', array('status' => 403));
}
if ($lastSign) {
$result = update_user_meta($uid, 'last_sign_at', $dayid, $lastSign);
} else {
$result = add_user_meta($uid, 'last_sign_at', $dayid, true);
}
if (!$result) {
return new WP_Error('failed', '签到失败', array('status' => 500));
}
while (true) {
$count = get_user_meta($uid, 'signed', true);
if (!$count) {
if (add_user_meta($uid, 'signed', 1, true)) {
do_action('signed_count_updated', array('uid' => $uid, 'count' => 1));
break;
}
} else {
if (update_user_meta($uid, 'signed', $count + 1, $count)) {
do_action('signed_count_updated', array('uid' => $uid, 'count' => $count + 1));
break;
}
}
}
return array("ok" => 1);
}
示例3: get_moodle_user_id
/**
* Get moodle user id. If the user does not exist in moodle then creats an user in moodle.
*
* @access private
* @param bool $create_moodle_user (default: bool)
* @return int
*/
private function get_moodle_user_id($create_moodle_user = false)
{
global $DC_Woodle;
$wc_order = $this->wc_order;
$user_id = $wc_order->get_user_id();
$email = $wc_order->billing_email;
$moodle_user_id = 0;
if ($user_id) {
$moodle_user_id = get_user_meta($user_id, '_moodle_user_id', true);
$moodle_user_id = intval($moodle_user_id);
$moodle_user_id = $this->search_for_moodle_user('id', array($moodle_user_id));
if (!$moodle_user_id) {
delete_user_meta($user_id, '_moodle_user_id');
}
}
if (!$moodle_user_id) {
$moodle_user_id = $this->search_for_moodle_user('email', array($email));
if ($moodle_user_id && $user_id) {
add_user_meta($user_id, '_moodle_user_id', $moodle_user_id);
}
}
if (!$moodle_user_id && $create_moodle_user) {
$moodle_user_id = $this->create_moodle_user();
if ($moodle_user_id && $user_id) {
add_user_meta($user_id, '_moodle_user_id', $moodle_user_id);
}
} else {
if (woodle_get_settings('update_user_info', 'dc_woodle_general') == 'yes') {
$this->update_moodle_user($moodle_user_id);
}
}
return $moodle_user_id;
}
示例4: registerUser
function registerUser()
{
if (isset($_POST['FullName']) && isset($_POST['InputPasswordSignup']) && isset($_POST['InputEmailSignup'])) {
/**
* @var \WegeTech\LottoYard\Service $lottoService
*/
global $lottoService;
$user = new User();
$name = explode(' ', $_POST['FullName']);
$user->FirstName = htmlspecialchars($name[0]);
$user->LastName = htmlspecialchars($name[1]);
$user->Email = $_POST['InputEmailSignup'];
$user->IP = $_SERVER['REMOTE_ADDR'];
$response = $lottoService->signUpUser($user);
if ($response->success) {
$userResponse = wp_create_user($_POST['InputEmailSignup'], $_POST['InputPasswordSignup'], $_POST['InputEmailSignup']);
if (is_wp_error($userResponse)) {
wp_send_json(array('message' => $userResponse->get_error_message()));
}
add_user_meta($userResponse, 'lottoPass', $response->data->Password, true);
loginUser($_POST['InputEmailSignup'], $_POST['InputPasswordSignup']);
wp_send_json(array('data' => $response->data));
} else {
wp_send_json(array('message' => $response->message));
}
}
}
示例5: __construct
private function __construct()
{
// Determine with the user ID if the user is logged in.
self::$userID = get_current_user_id();
// Generate link for mark all forums read.
self::$markAllReadLink = esc_url(add_query_arg(array('view' => 'markallread'), get_permalink()));
// Initialize data. For guests we use a cookie as source, otherwise use database.
if (self::$userID) {
// Create database entry when it does not exist.
if (!get_user_meta(self::$userID, 'asgarosforum_unread_cleared', true)) {
add_user_meta(self::$userID, 'asgarosforum_unread_cleared', '0000-00-00 00:00:00');
}
// Get IDs of excluded topics.
self::$excludedItems = get_user_meta(self::$userID, 'asgarosforum_unread_exclude', true);
} else {
// Create a cookie when it does not exist.
if (!isset($_COOKIE['asgarosforum_unread_cleared'])) {
// There is no cookie set so basically the forum has never been visited.
setcookie('asgarosforum_unread_cleared', '0000-00-00 00:00:00', 2147483647);
}
// Get IDs of excluded topics.
if (isset($_COOKIE['asgarosforum_unread_exclude'])) {
self::$excludedItems = maybe_unserialize($_COOKIE['asgarosforum_unread_exclude']);
}
}
}
示例6: register_config_groups
public function register_config_groups()
{
wp_register_script('peepso-blogposts-config', plugin_dir_url(__FILE__) . '../assets/js/blogposts-config.js', array('jquery'), PeepSo::PLUGIN_VERSION, TRUE);
wp_enqueue_script('peepso-blogposts-config');
if (isset($_GET['admin_tutorial_reset'])) {
delete_user_meta(PeepSo::get_user_id(), 'peepso_blogposts_admin_tutorial_hide');
PeepSo::redirect(admin_url() . 'admin.php?page=peepso_config&tab=blogposts');
}
if (isset($_GET['admin_tutorial_hide'])) {
add_user_meta(PeepSo::get_user_id(), 'peepso_blogposts_admin_tutorial_hide', 1, TRUE);
PeepSo::redirect(admin_url() . 'admin.php?page=peepso_config&tab=blogposts');
}
// display the admin tutorial unless this user has already hidden it
if (1 != get_user_meta(PeepSo::get_user_id(), 'peepso_blogposts_admin_tutorial_hide', TRUE)) {
ob_start();
PeepSoTemplate::exec_template('blogposts', 'admin_tutorial');
$peepso_admin = PeepSoAdmin::get_instance();
$peepso_admin->add_notice(ob_get_clean(), '');
}
$this->context = 'left';
$this->group_profile();
$this->group_acknowledgements();
$this->context = 'right';
$this->group_activity();
$this->group_post_types();
}
示例7: wpanswer_user_registration_action_handler
function wpanswer_user_registration_action_handler($user_id)
{
global $wpdb, $wpanswer_user_approve;
if ($wpanswer_user_approve->configs->get_value('wpanswer_enable_manual_registration_approval') == '1') {
$res = add_user_meta($user_id, 'wpanswer_account_status', 'pending');
}
}
示例8: userRegister
function userRegister()
{
$this->verifyNonce('userRegister');
$data = $_POST["data"];
$userID = wp_insert_user(array('first_name' => $data["first_name"], 'last_name' => $data["last_name"], 'nickname' => $data["nickname"], 'user_email' => $data["user_email"], 'user_login' => $data["user_login"], 'user_pass' => $data["user_pass"]));
/*
Add a custom capability to the user
$user = new WP_User($userID);
$user->add_cap("edit_posts");
$user->add_cap("delete_posts");
*/
if (isset($userID->errors)) {
echo json_encode($userID);
} else {
//Add USER INFO
add_user_meta($userID, "adress", $data["adress"], true);
add_user_meta($userID, "localidade", $data["localidade"], true);
add_user_meta($userID, "codPostal", $data["codPostal"], true);
add_user_meta($userID, "treinador", "Não atribuido", true);
//Notify user and admin that a new user arrived
wp_new_user_notification($userID, '', 'both');
echo '{"userID": "' . $userID . '"}';
}
wp_die();
}
示例9: WP_members_list_meta_actions
function WP_members_list_meta_actions($i)
{
global $getWP, $tern_wp_members_defaults, $current_user, $wpdb, $profileuser, $current_user, $getMap;
$o = $getWP->getOption('tern_wp_members', $tern_wp_members_defaults);
get_currentuserinfo();
if (!current_user_can('edit_users') and ($o['allow_display'] and $current_user->ID != $i or !$o['allow_display'])) {
return;
}
global $getWP, $tern_wp_members_defaults, $current_user, $wpdb, $profileuser;
$o = $getWP->getOption('tern_wp_members', $tern_wp_members_defaults);
delete_user_meta($i, '_tern_wp_member_list');
foreach ((array) $_REQUEST['lists'] as $v) {
add_user_meta($i, '_tern_wp_member_list', $v);
}
$a = array('line1', 'line2', 'city', 'state', 'zip');
foreach ($a as $v) {
delete_user_meta($i, '_' . $v);
add_user_meta($i, '_' . $v, $_POST[$v]);
$address[$v] = $_POST[$v];
}
//delete_user_meta($i,'_address');
//add_user_meta($i,'_address',$address);
$l = $getMap->geoLocate($address);
delete_user_meta($i, '_lat');
delete_user_meta($i, '_lng');
add_user_meta($i, '_lat', $l['lat']);
add_user_meta($i, '_lng', $l['lng']);
}
示例10: baseignore
public function baseignore()
{
$uid = get_current_user_id();
if (isset($_GET['fileaway_dismiss_config_notice']) && '0' == $_GET['fileaway_dismiss_config_notice']) {
add_user_meta($uid, 'fileaway_dismiss_config_notice', 'true', true);
}
}
示例11: optionsframework_nag_ignore
function optionsframework_nag_ignore() {
global $current_user;
$user_id = $current_user->ID;
if ( isset( $_GET['optionsframework_nag_ignore'] ) && '0' == $_GET['optionsframework_nag_ignore'] ) {
add_user_meta( $user_id, 'optionsframework_ignore_notice', 'true', true );
}
}
示例12: lhg_set_donation
function lhg_set_donation()
{
$user_id = get_current_user_id();
//get user locale with user id
$user_donation_target = get_user_meta($user_id, 'user_donation_target', true);
//debug:
//echo "UL1: $user_language";
if ($user_donation_target == "") {
//add default locale
#echo "Unknown donation target ($user_donation_target)";
add_user_meta($user_id, 'user_donation_target', '1');
$user_donation_target = 1;
} else {
#echo "Found: $user_donation_target";
}
?>
<tr>
<th scope="row"> Karma points are donated to
</th>
<td>
<select name="lhg_user_donation_target">
<?php
lhg_donation_selector($user_donation_target);
?>
</select>
</td>
</tr>
<?php
}
示例13: bogo_update_user_option
function bogo_update_user_option($user_id)
{
global $wpdb;
$meta_key = $wpdb->get_blog_prefix() . 'accessible_locale';
if (!empty($_POST['setting_bogo_accessible_locales'])) {
delete_user_meta($user_id, $meta_key);
if (isset($_POST['bogo_accessible_locales'])) {
$locales = (array) $_POST['bogo_accessible_locales'];
$locales = bogo_filter_locales($locales);
foreach ($locales as $locale) {
add_user_meta($user_id, $meta_key, $locale);
}
}
if (!metadata_exists('user', $user_id, $meta_key)) {
add_user_meta($user_id, $meta_key, 'zxx');
// zxx is a special code in ISO 639-2
}
}
if (isset($_POST['bogo_own_locale'])) {
$locale = trim($_POST['bogo_own_locale']);
if (bogo_is_available_locale($locale)) {
update_user_option($user_id, 'locale', $locale, true);
}
}
}
示例14: add_user_meta
public function add_user_meta()
{
if (self::$current == null || $this->name != self::$current) {
return;
}
add_user_meta($this->get_current_user_id(), self::$current, 'seen', true);
}
示例15: Complete_new_user_creation
public function Complete_new_user_creation($user_id)
{
add_user_meta($user_id, 'browserid_registration', $this->user_registering_with_browserid);
if ($this->user_registering_with_browserid) {
$this->login->Login_by_id($user_id, false);
}
}