本文整理汇总了PHP中update_user_option函数的典型用法代码示例。如果您正苦于以下问题:PHP update_user_option函数的具体用法?PHP update_user_option怎么用?PHP update_user_option使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。
在下文中一共展示了update_user_option函数的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: __construct
public function __construct()
{
parent::__construct();
if (isset($_REQUEST['shipping_module_id'])) {
update_user_option(get_current_user_id(), 'wpsc_settings_selected_shipping_module', $_REQUEST['shipping_module_id']);
}
}
示例2: hide
/**
* Stores user's preference to hide the submit message via AJAX
*/
function hide()
{
check_ajax_referer($this->parent->slug_ . '_hide_submit', '_ajax_nonce-' . $this->parent->slug . '-hide-submit');
//note: option will be global
update_user_option(get_current_user_ID(), 'infinite-scroll-hide-submit', true, true);
die(1);
}
示例3: wpu_check_for_action
function wpu_check_for_action()
{
global $user_ID, $wp_version;
if (isset($_GET['wpu_action'])) {
if ('activate' == $_GET['wpu_action']) {
check_admin_referer('wp-united-switch-theme_' . $_GET['template']);
if (isset($_GET['template'])) {
update_usermeta($user_ID, 'WPU_MyTemplate', $_GET['template']);
}
if (isset($_GET['stylesheet'])) {
update_usermeta($user_ID, 'WPU_MyStylesheet', $_GET['stylesheet']);
}
$wpuConnSettings = get_settings('wputd_connection');
wp_redirect('admin.php?page=' . $wpuConnSettings['full_path_to_plugin'] . '&activated=true&wputab=themes');
exit;
} elseif ('update-blog-profile' == $_GET['wpu_action']) {
check_admin_referer('update-blog-profile_' . $user_ID);
$errors = edit_user($user_ID);
//$errors behaves differently post-WP 2.1
if ((double) $wp_version >= 2.1) {
//WordPress >= 2.1
if (is_wp_error($errors)) {
foreach ($errors->get_error_messages() as $message) {
echo "<li>{$message}</li>";
}
}
} else {
//WP 2.0x
if (is_array($errors)) {
if (count($errors) != 0) {
foreach ($errors as $id => $error) {
echo $error . '<br/>';
}
exit;
}
}
}
if (!isset($_POST['rich_editing'])) {
$_POST['rich_editing'] = 'false';
}
update_user_option($current_user->id, 'rich_editing', $_POST['rich_editing'], true);
//
// UPDATE BLOG DETAILS
//
$blog_title = __('My Blog');
$blog_tagline = __('My description will go here');
if (isset($_POST['blog_title'])) {
$blog_title = wp_specialchars(trim($_POST['blog_title']));
}
if (isset($_POST['blog_tagline'])) {
$blog_tagline = wp_specialchars(trim($_POST['blog_tagline']));
}
update_usermeta($user_ID, 'blog_title', $blog_title);
update_usermeta($user_ID, 'blog_tagline', $blog_tagline);
$wpuConnSettings = get_settings('wputd_connection');
wp_redirect('admin.php?page=' . $wpuConnSettings['full_path_to_plugin'] . '&updated=true&wputab=bset');
exit;
}
}
}
示例4: yoimg_crop_load_styles_and_scripts
function yoimg_crop_load_styles_and_scripts($hook)
{
if (YOIMG_CROP_ENABLED) {
if ($hook == 'post.php') {
wp_enqueue_media();
} else {
if ($hook == 'upload.php') {
// issue http://stackoverflow.com/questions/25884434/wordpress-wp-enqueue-media-causes-javascript-error-from-wp-admin-upload-phpmo
$mode = get_user_option('media_library_mode', get_current_user_id()) ? get_user_option('media_library_mode', get_current_user_id()) : 'grid';
$modes = array('grid', 'list');
if (isset($_GET['mode']) && in_array($_GET['mode'], $modes)) {
$mode = $_GET['mode'];
update_user_option(get_current_user_id(), 'media_library_mode', $mode);
}
if ('list' === $mode) {
$version = get_bloginfo('version');
// issue https://wordpress.org/support/topic/findposts-is-not-defined
if (version_compare($version, '4.2.2') < 0) {
wp_dequeue_script('media');
}
wp_enqueue_media();
}
} else {
wp_enqueue_style('media-views');
}
}
wp_enqueue_style('wp-pointer');
wp_enqueue_style('yoimg-cropping-css', YOIMG_CROP_URL . '/css/yoimg-cropping.css');
wp_enqueue_style('yoimg-cropper-css', YOIMG_CROP_URL . '/js/cropper/cropper.min.css');
wp_enqueue_script('wp-pointer');
wp_enqueue_script('yoimg-cropper-js', YOIMG_CROP_URL . '/js/cropper/cropper.min.js', array('jquery'), false, true);
wp_enqueue_script('yoimg-cropping-js', YOIMG_CROP_URL . '/js/yoimg-cropping.js', array('yoimg-cropper-js'), false, true);
}
}
示例5: registrar_usuario
function registrar_usuario($parametros)
{
$errors = new WP_Error();
if ($parametros['email'] == NULL) {
$errors->add('empty_email', __('<strong>ERROR</strong>: Please type your e-mail address.'));
return $errors;
}
if (!es_email($parametros['email'])) {
$errors->add('invalid_email', __('<strong>ERROR</strong>: The email address isn’t correct.'));
return $errors;
}
if (email_exists($parametros['email'])) {
$errors->add('email_exists', __('<strong>ERROR</strong>: This email is already registered, please choose another one.'));
return $errors;
}
if ($parametros['nombre'] == NULL) {
$errors->add('empty_username', __('<strong>ERROR</strong>: Please enter a username.'));
return $errors;
}
$user_pass = $parametros['clave'] == NULL ? wp_generate_password(12, false) : $parametros['clave'];
$user_id = wp_create_user($parametros['email'], $user_pass, $parametros['email']);
if (!$user_id) {
$errors->add('registerfail', sprintf(__('<strong>ERROR</strong>: Couldn’t register you... please contact the <a href="mailto:%s">webmaster</a> !'), get_option('admin_email')));
return $errors;
}
update_user_option($user_id, 'default_password_nag', true, true);
//Set up the Password change nag.
wp_new_user_notification($user_id, $user_pass);
// Actualización de tabla clientes...
return $user_id;
}
示例6: save_metabox
/**
* Save the meta box data.
*/
public function save_metabox($post_id)
{
/*
Verify using the nonce that the data was submitted from our meta box on our site.
If it wasn't, return the post ID and be on our way.
*/
// If no nonce was provided or the nonce does not match
if (!isset($_POST[CCFIC_KEY . '_nonce']) || !wp_verify_nonce($_POST[CCFIC_KEY . '_nonce'], CCFIC_ID)) {
return $post_id;
}
// Make sure the user has valid permissions
// If we're editing a page and the user isn't allowed to do that, return the post ID
if ('page' == $_POST['post_type']) {
if (!current_user_can('edit_page', $post_id)) {
return $post_id;
}
} else {
if (!current_user_can('edit_post', $post_id)) {
return $post_id;
}
}
// Now that we've validated nonce and permissions, let's save the caption data
// Sanitize the caption
$caption = array('caption_text' => $_POST[CCFIC_KEY . '_caption_text'], 'source_text' => $_POST[CCFIC_KEY . '_source_text'], 'source_url' => esc_url($_POST[CCFIC_KEY . '_source_url']), 'new_window' => !empty($_POST[CCFIC_KEY . '_new_window']) ? true : false);
// Update the caption meta field
update_post_meta($post_id, '_' . CCFIC_KEY, $caption);
// Update the user default for the "new window" checkbox
update_user_option(get_current_user_id(), CCFIC_KEY . '_new_window', $caption['new_window']);
}
示例7: enqueueTheGoods
/**
* Enqueue the CSS and JS needed to make the magic happen
* @param $hook
*/
public function enqueueTheGoods($hook)
{
add_thickbox();
if ($hook == 'post.php') {
wp_enqueue_media();
} else {
if ($hook == 'upload.php') {
$mode = get_user_option('media_library_mode', get_current_user_id()) ? get_user_option('media_library_mode', get_current_user_id()) : 'grid';
if (isset($_GET['mode']) && in_array($_GET['mode'], ['grid', 'list'])) {
$mode = $_GET['mode'];
update_user_option(get_current_user_id(), 'media_library_mode', $mode);
}
if ($mode == 'list') {
$version = get_bloginfo('version');
if (version_compare($version, '4.2.2') < 0) {
wp_dequeue_script('media');
}
wp_enqueue_media();
}
} else {
wp_enqueue_style('media-views');
}
}
wp_enqueue_style('wp-pointer');
wp_enqueue_style('ilab-modal-css', ILAB_PUB_CSS_URL . '/ilab-modal.min.css');
wp_enqueue_style('ilab-media-tools-css', ILAB_PUB_CSS_URL . '/ilab-media-tools.min.css');
wp_enqueue_script('wp-pointer');
wp_enqueue_script('ilab-modal-js', ILAB_PUB_JS_URL . '/ilab-modal.js', ['jquery'], false, true);
wp_enqueue_script('ilab-media-tools-js', ILAB_PUB_JS_URL . '/ilab-media-tools.js', ['jquery'], false, true);
}
示例8: wr_contactform_ajax_hidden_columns
function wr_contactform_ajax_hidden_columns()
{
// Set custom error reporting level
error_reporting(E_ALL ^ E_NOTICE);
if (!empty($_POST)) {
$form = !empty($_POST['form_id']) ? $_POST['form_id'] : '';
$postColumns = !empty($_POST['columns']) ? $_POST['columns'] : '';
if (!empty($form)) {
if (!($user = wp_get_current_user())) {
wp_die(-1);
}
$columns = array();
$getColumns = get_user_option('wr_cfsb_post_type_column', $user->ID);
if (!empty($getColumns)) {
$columns = $getColumns;
$columns[$form] = $postColumns;
} else {
$columns[$form] = $postColumns;
}
update_user_option($user->ID, 'wr_cfsb_post_type_column', $columns, true);
}
} else {
if (!empty($_GET)) {
$form = !empty($_GET['form_id']) ? $_GET['form_id'] : '';
if (!($user = wp_get_current_user())) {
wp_die(-1);
}
$columns = get_user_option('wr_cfsb_post_type_column', $user->ID);
$data = !empty($columns[$form]) ? json_encode($columns[$form]) : '';
echo '' . $data;
}
}
exit;
}
示例9: wp_new_user_notification
function wp_new_user_notification($user_id, $plaintext_pass = '')
{
global $pagenow;
global $register_plus_redux;
//trigger_error( sprintf( __( 'Register Plus Redux DEBUG: wp_new_user_notification($user_id=%s, $plaintext_pass=%s) from %s', 'register-plus-redux' ), $user_id, $plaintext_pass, $pagenow ) );
if ('1' === $register_plus_redux->rpr_get_option('user_set_password') && !empty($_POST['pass1'])) {
$plaintext_pass = stripslashes((string) $_POST['pass1']);
}
if ('user-new.php' === $pagenow && !empty($_POST['pass1'])) {
$plaintext_pass = stripslashes((string) $_POST['pass1']);
}
if ('1' === $register_plus_redux->rpr_get_option('user_set_password')) {
update_user_option($user_id, 'default_password_nag', false, true);
}
// turn off the Password change nag.
do_action('rpr_new_user', $user_id, $plaintext_pass);
//TODO: Code now only forces users registering to verify email, may want to add settings to have admin created users verify email too
$verification_code = '';
$user_registering = 'wp-login.php' === $pagenow || $register_plus_redux->rpr_wp_modal_registration();
if ($user_registering && '1' === $register_plus_redux->rpr_get_option('verify_user_email')) {
$verification_code = wp_generate_password(20, FALSE);
update_user_meta($user_id, 'email_verification_code', $verification_code);
update_user_meta($user_id, 'email_verification_sent', gmdate('Y-m-d H:i:s'));
$register_plus_redux->send_verification_mail($user_id, $verification_code);
}
if ($user_registering && '1' !== $register_plus_redux->rpr_get_option('disable_user_message_registered') || !$user_registering && '1' !== $register_plus_redux->rpr_get_option('disable_user_message_created')) {
if ('1' !== $register_plus_redux->rpr_get_option('verify_user_email') && '1' !== $register_plus_redux->rpr_get_option('verify_user_admin')) {
$register_plus_redux->send_welcome_user_mail($user_id, $plaintext_pass);
}
}
if ($user_registering && '1' !== $register_plus_redux->rpr_get_option('disable_admin_message_registered') || !$user_registering && '1' !== $register_plus_redux->rpr_get_option('disable_admin_message_created')) {
$register_plus_redux->send_admin_mail($user_id, $plaintext_pass, $verification_code);
}
}
示例10: process_registration
public function process_registration()
{
do_action('popmake_alm_ajax_override_registration');
$user_login = $_POST['user_login'];
$user_email = $_POST['user_email'];
$user_pass = isset($_POST['user_pass']) ? $_POST['user_pass'] : wp_generate_password(12, false);
$userdata = compact('user_login', 'user_email', 'user_pass');
$user = wp_insert_user($userdata);
if (!isset($_POST['user_pass'])) {
update_user_option($user, 'default_password_nag', true, true);
// Set up the Password change nag.
wp_new_user_notification($user, $user_pass);
}
if (is_wp_error($user)) {
$response = array('success' => false, 'message' => $user->get_error_message());
} else {
if (popmake_get_popup_ajax_registration($_POST['popup_id'], 'enable_autologin')) {
$creds = array('user_login' => $user_login, 'user_password' => $user_pass, 'remember' => true);
$user = wp_signon($creds);
}
$message = __('Registration complete.', 'popup-maker-ajax-login-modals');
if (!isset($_POST['user_pass'])) {
$message .= ' ' . __('Please check your e-mail.', 'popup-maker-ajax-login-modals');
}
$response = array('success' => true, 'message' => $message);
}
echo json_encode($response);
die;
}
示例11: run
public function run($arguments)
{
global $itsec_globals;
if (!isset($arguments['id'])) {
return false;
//User not provided
}
$user = get_user_by('id', intval($arguments['id']));
if ($user === false) {
return false;
//user doesn't exist
}
$direction = isset($arguments['direction']) ? $arguments['direction'] : 'add';
$enabled = trim(get_user_option('itsec_two_factor_enabled', $user->ID));
$override = intval(get_user_option('itsec_two_factor_override', $user->ID)) === 1 ? true : false;
$override_expires = intval(get_user_option('itsec_two_factor_override_expires', $user->ID));
if ($direction === 'add') {
if ($enabled != 'on' || $override !== 1 && $itsec_globals['current_time'] < $override_expires) {
return false;
//Override already active
}
$override = true;
$override_expires = $itsec_globals['current_time'] + 600;
$response = array('ID' => $user->ID, 'user_login' => $user->user_login, 'override' => $override, 'override_expires' => $override_expires);
update_user_option($user->ID, 'itsec_two_factor_override', $override, true);
update_user_option($user->ID, 'itsec_two_factor_override_expires', $override_expires, true);
return $response;
} elseif ($direction === 'remove') {
delete_user_option($user->ID, 'itsec_two_factor_override', true);
delete_user_option($user->ID, 'itsec_two_factor_override_expires', true);
return true;
}
return false;
}
开发者ID:femgineer,项目名称:website,代码行数:34,代码来源:class-ithemes-sync-verb-itsec-override-two-factor-user.php
示例12: dashboard_widget_controls
/**
* Display the dashboard widget controls content.
*/
public static function dashboard_widget_controls()
{
$number_of_days = self::get_number_of_days();
$current_filter = self::get_current_filter();
$available_filters = activity_heat_map_get_filters();
if (isset($_REQUEST['activity_heat_map_filter'])) {
$current_filter = sanitize_text_field($_REQUEST['activity_heat_map_filter']);
if (!array_key_exists($current_filter, $available_filters)) {
$current_filter = 'posts';
}
update_user_option(get_current_user_id(), 'activity_heat_map_filter', $current_filter);
}
if (isset($_REQUEST['activity_heat_map_days'])) {
$number_of_days = absint($_REQUEST['activity_heat_map_days']);
$number_of_days = $number_of_days <= 366 ? $number_of_days : 366;
update_user_option(get_current_user_id(), 'activity_heat_map_days', $number_of_days);
}
echo '<p>';
printf('<label for="activity_heat_map_filter">%s</label>', esc_html__('Show activity: ', 'activity-heat-map'));
echo '<select name="activity_heat_map_filter" id="activity_heat_map_filter">';
foreach ($available_filters as $filter => $data) {
printf('<option value="%s" %s>%s</option>', esc_attr($filter), selected($current_filter, $filter), esc_html($data['title']));
}
echo '</select>';
echo '</p>';
echo '<p>';
printf('<label for="activity_heat_map_days">%s</label>', esc_html__('Number of days: ', 'activity-heat-map'));
printf('<input type="number" min="7" max="366" name="activity_heat_map_days" id="activity_heat_map_days" value="%s" />', absint($number_of_days));
echo '</p>';
}
示例13: wp_edit
function wp_edit()
{
global $post_type, $wp_query;
if ($post_type != GALLERY_POST_TYPE_SLUG) {
return;
}
if (!current_user_can('edit_others_pages') || !post_type_supports($post_type, 'page-attributes') && !is_post_type_hierarchical($post_type)) {
// check permission
return;
}
add_action('restrict_manage_posts', array($this, 'restrict_manage_posts'));
// posts per page drop down UI
if (isset($_GET['per_page']) && ($_GET['per_page'] == 99999 || $_GET['per_page'] % 10 == 0)) {
update_user_option(get_current_user_id(), 'edit_' . $post_type . '_per_page', (int) $_GET['per_page']);
}
add_filter('views_' . get_current_screen()->id, array($this, 'sort_by_order_link'));
// add view by menu order to views
add_filter('contextual_help', array($this, 'contextual_help'));
// add contextual help to hierarchical post screens
#if ( $wp_query->query['orderby'] == 'menu_order title' ) { // we can only sort if we're organized by menu order; WP 3.2 and 3.1 versions
wp_enqueue_script('simple-page-ordering', THEMEURL . 'inc/gallery-ordering/simple-page-ordering.js', array('jquery-ui-sortable'), '0.9.7', true);
$js_trans = array('RepositionTree' => __("Items can only be repositioned within their current branch in the page tree / hierarchy (next to pages with the same parent).\n\nIf you want to move this item into a different part of the page tree, use the Quick Edit feature to change the parent before continuing.", TD));
#wp_localize_script( 'simple-page-ordering', 'simple_page_ordering_l10n', $js_trans );
#}
}
示例14: 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);
}
}
}
示例15: addAuthenticatorCheckCode
/**
* Function for checking authorization to add as
* a primary filter to control user and password
*/
function addAuthenticatorCheckCode($userobj, $username, $password)
{
// If option at the user level is off I go out from the procedure
// without other controls on the verification code twice
if (!isset($userobj->ID) or trim(get_user_option('sz_google_authenticator_enabled', $userobj->ID)) != '1') {
return $userobj;
}
// Checking and setting variables and secret code entered
// A profile is stored in the master and the other is passed by login
if (empty($_POST['googleauthotp'])) {
$authenticator = '';
} else {
$authenticator = trim($_POST['googleauthotp']);
}
$options = $this->getModuleOptions('SZGoogleModuleAuthenticator');
$secrets = trim(get_user_option('sz_google_authenticator_secret', $userobj->ID));
// Control code inserted into the login form
// with those in the table of secret codes Emergency
if ($options['authenticator_emergency_codes'] == '1') {
$em = unserialize(trim(get_user_option('sz_google_authenticator_codes', $userobj->ID)));
if (is_array($em) and isset($em[$authenticator]) and $em[$authenticator] == false) {
$em[$authenticator] = time();
update_user_option($userobj->ID, 'sz_google_authenticator_codes', serialize($em), true);
return $userobj;
}
}
// Control code inserted into the login form with
// that calculated routine internal authenticator class
if ($this->checkAuthenticatorCode($secrets, $authenticator, $options['authenticator_discrepancy']) === true) {
return $userobj;
} else {
return new WP_Error('invalid_google_authenticator_password', SZGoogleCommon::getTranslate('<strong>ERROR</strong>: Authenticator code is incorrect.', 'sz-google'));
}
}