本文整理汇总了PHP中delete_user_option函数的典型用法代码示例。如果您正苦于以下问题:PHP delete_user_option函数的具体用法?PHP delete_user_option怎么用?PHP delete_user_option使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。
在下文中一共展示了delete_user_option函数的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: users
/**
* Generate users
*
* @param array $args
* @param array $assoc_args
**/
public function users($args, $assoc_args)
{
global $blog_id;
$defaults = array('count' => 100, 'role' => get_option('default_role'));
extract(wp_parse_args($assoc_args, $defaults), EXTR_SKIP);
if ('none' == $role) {
$role = false;
} elseif (is_null(get_role($role))) {
WP_CLI::warning("invalid role.");
exit;
}
$user_count = count_users();
$total = $user_count['total_users'];
$limit = $count + $total;
$notify = new \cli\progress\Bar('Generating users', $count);
for ($i = $total; $i < $limit; $i++) {
$login = sprintf('user_%d_%d', $blog_id, $i);
$name = "User {$i}";
$user_id = wp_insert_user(array('user_login' => $login, 'user_pass' => $login, 'nickname' => $name, 'display_name' => $name, 'role' => $role));
if (false === $role) {
delete_user_option($user_id, 'capabilities');
delete_user_option($user_id, 'user_level');
}
$notify->tick();
}
$notify->finish();
}
示例2: 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
示例3: initMenu
public static function initMenu()
{
self::$page = MainWPManageSitesView::initMenu();
add_submenu_page('mainwp_tab', __('Sites Help', 'mainwp'), '<div class="mainwp-hidden">' . __('Sites Help', 'mainwp') . '</div>', 'read', 'SitesHelp', array(MainWPManageSites::getClassName(), 'QSGManageSites'));
if (isset($_REQUEST['dashboard'])) {
global $current_user;
delete_user_option($current_user->ID, 'screen_layout_toplevel_page_managesites');
add_filter('screen_layout_columns', array(self::getClassName(), 'on_screen_layout_columns'), 10, 2);
$val = get_user_option('screen_layout_' . self::$page);
if (!MainWPUtility::ctype_digit($val)) {
global $current_user;
update_user_option($current_user->ID, 'screen_layout_' . self::$page, 2, true);
}
add_action('load-' . MainWPManageSites::$page, array(MainWPManageSites::getClassName(), 'on_load_page_dashboard'));
} else {
// add_action('load-'.MainWPManageSites::$page, array(MainWPManageSites::getClassName(), 'on_load_page_manage'));
add_action('load-' . MainWPManageSites::$page, array(MainWPManageSites::getClassName(), 'add_options'));
}
add_submenu_page('mainwp_tab', 'Sites', '<div class="mainwp-hidden">Sites</div>', 'read', 'SiteOpen', array(MainWPSiteOpen::getClassName(), 'render'));
add_submenu_page('mainwp_tab', 'Sites', '<div class="mainwp-hidden">Sites</div>', 'read', 'SiteRestore', array(MainWPSiteOpen::getClassName(), 'renderRestore'));
self::$subPages = apply_filters('mainwp-getsubpages-sites', array());
if (isset(self::$subPages) && is_array(self::$subPages)) {
foreach (self::$subPages as $subPage) {
add_submenu_page('mainwp_tab', $subPage['title'], '<div class="mainwp-hidden">' . $subPage['title'] . '</div>', 'read', 'ManageSites' . $subPage['slug'], $subPage['callback']);
}
}
}
示例4: create
/**
* Create a user
*
* @param array $args
* @param array $assoc_args
**/
public function create($args, $assoc_args)
{
global $blog_id;
if (count($args) < 2) {
WP_CLI::error("Login and email required.");
}
list($user_login, $user_email) = $args;
$defaults = array('role' => get_option('default_role'), 'user_pass' => wp_generate_password(), 'user_registered' => strftime("%F %T", time()), 'display_name' => false);
extract(wp_parse_args($assoc_args, $defaults), EXTR_SKIP);
if ('none' == $role) {
$role = false;
} elseif (is_null(get_role($role))) {
WP_CLI::error("Invalid role.");
}
$user_id = wp_insert_user(array('user_email' => $user_email, 'user_login' => $user_login, 'user_pass' => $user_pass, 'user_registered' => $user_registered, 'display_name' => $display_name, 'role' => $role));
if (is_wp_error($user_id)) {
WP_CLI::error($user_id);
} else {
if (false === $role) {
delete_user_option($user_id, 'capabilities');
delete_user_option($user_id, 'user_level');
}
}
if (isset($assoc_args['porcelain'])) {
WP_CLI::line($user_id);
} else {
WP_CLI::success("Created user {$user_id}.");
}
}
示例5: display
public function display()
{
if (isset($_GET['form_id'])) {
if ('new' == $_GET['form_id']) {
$form_id = 'tmp-' . time();
} else {
$form_id = is_numeric($_GET['form_id']) ? absint($_GET['form_id']) : '';
}
/*
* FORM BUILDER
*/
Ninja_Forms::template('admin-menu-new-form.html.php');
$this->_enqueue_the_things($form_id);
delete_user_option(get_current_user_id(), 'nf_form_preview_' . $form_id);
if (!isset($_GET['ajax'])) {
$this->_localize_form_data($form_id);
$this->_localize_field_type_data();
$this->_localize_action_type_data();
$this->_localize_form_settings();
$this->_localize_merge_tags();
}
} else {
/*
* ALL FORMS TABLE
*/
$this->table->prepare_items();
Ninja_Forms::template('admin-menu-all-forms.html.php', array('table' => $this->table, 'add_new_url' => admin_url('admin.php?page=ninja-forms&form_id=new'), 'add_new_text' => __('Add New Form', 'ninja-forms')));
}
}
示例6: clearAllTwitterMessages
public static function clearAllTwitterMessages()
{
$filters = self::get_filter();
$user_id = get_current_user_id();
foreach ($filters as $what) {
$opt_name = 'mainwp_tt_message_' . $what;
delete_user_option($user_id, $opt_name);
}
}
示例7: save
public function save()
{
check_ajax_referer('ninja_forms_ajax_nonce', 'security');
if (!isset($_POST['form'])) {
$this->_errors[] = 'Form Not Found';
$this->_respond();
}
$form_data = json_decode(stripslashes($_POST['form']), ARRAY_A);
if (is_string($form_data['id'])) {
$tmp_id = $form_data['id'];
$form = Ninja_Forms()->form()->get();
$form->save();
$form_data['id'] = $form->get_id();
$this->_data['new_ids']['forms'][$tmp_id] = $form_data['id'];
} else {
$form = Ninja_Forms()->form($form_data['id'])->get();
}
$form->update_settings($form_data['settings'])->save();
if (isset($form_data['fields'])) {
foreach ($form_data['fields'] as $field_data) {
$id = $field_data['id'];
$field = Ninja_Forms()->form($form_data['id'])->get_field($id);
$field->update_settings($field_data['settings'])->save();
if ($field->get_tmp_id()) {
$tmp_id = $field->get_tmp_id();
$this->_data['new_ids']['fields'][$tmp_id] = $field->get_id();
}
$this->_data['fields'][$id] = $field->get_settings();
}
}
if (isset($form_data['deleted_fields'])) {
foreach ($form_data['deleted_fields'] as $deleted_field_id) {
$field = Ninja_Forms()->form()->get_field($deleted_field_id);
$field->delete();
}
}
if (isset($form_data['actions'])) {
foreach ($form_data['actions'] as $action_data) {
$id = $action_data['id'];
$action = Ninja_Forms()->form($form_data['id'])->get_action($action_data['id']);
$action->update_settings($action_data['settings'])->save();
if ($action->get_tmp_id()) {
$tmp_id = $action->get_tmp_id();
$this->_data['new_ids']['actions'][$tmp_id] = $action->get_id();
}
$this->_data['actions'][$id] = $action->get_settings();
}
}
if (isset($form_data['deleted_actions'])) {
foreach ($form_data['deleted_actions'] as $deleted_action_id) {
$action = Ninja_Forms()->form()->get_action($deleted_action_id);
$action->delete();
}
}
delete_user_option(get_current_user_id(), 'nf_form_preview_' . $form_data['id']);
$this->_respond();
}
示例8: hmn_cp_v121_upgrade
/**
* Copy unprefixed option value to new prefixed option.
*/
function hmn_cp_v121_upgrade()
{
$users = get_users();
foreach ($users as $user) {
$hmn_comments_voted_on = get_user_option('comments_voted_on', $user->ID);
if (!$hmn_comments_voted_on) {
continue;
}
update_user_option($user->ID, 'hmn_comments_voted_on', $hmn_comments_voted_on);
delete_user_option($user->ID, 'comments_voted_on', true);
}
}
示例9: was_uninstall_options
/**
* Delete all WAS saved options.
*
* @since 0.1
*/
function was_uninstall_options()
{
global $wpdb;
// Delete all the user options
$users = $wpdb->get_col('SELECT `' . $wpdb->users . ID . '` FROM `' . $wpdb->users . '`');
foreach ($users as $user_id) {
delete_user_option($user_id, 'was_show_per_page');
}
// Delete all the defined options
delete_option('was_db_version');
delete_option('was_show_per_page');
}
示例10: bbp_delete_user_options
/**
* Delete default user options
*
* Hooked to bbp_uninstall, it is only called once when bbPress is uninstalled.
* This is destructive, so existing bbPress user options will be destroyed.
*
* @since 2.1.0 bbPress (r3910)
*
* @uses bbp_get_default_user_options() To get default options
* @uses delete_user_option() Removes default options
* @uses do_action() Calls 'bbp_delete_options'
*/
function bbp_delete_user_options($user_id = 0)
{
// Validate user id
$user_id = bbp_get_user_id($user_id);
if (empty($user_id)) {
return;
}
// Add default options
foreach (array_keys(bbp_get_default_user_options()) as $key) {
delete_user_option($user_id, $key);
}
// Allow previously activated plugins to append their own options.
do_action('bbp_delete_user_options', $user_id);
}
示例11: dpa_delete_user_options
/**
* Delete default user options
*
* Hooked to dpa_uninstall, it is only called once when Achievements is uninstalled.
* This is destructive, so existing Achievements user options will be destroyed.
*
* @param int $user_id Optional; defaults to current user
* @since Achievements (3.0)
*/
function dpa_delete_user_options($user_id = 0)
{
// Default to current user
if (empty($user_id) && is_user_logged_in()) {
$user_id = get_current_user_id();
}
// No user, bail out
if (empty($user_id)) {
return;
}
// Delete default options (both per site and per network)
foreach (array_keys(dpa_get_default_user_options()) as $key => $value) {
delete_user_option($user_id, $key, false);
delete_user_option($user_id, $key, true);
}
// Allow previously activated plugins to append their own options.
do_action('dpa_delete_user_options', $user_id);
}
示例12: on_admin_menu
function on_admin_menu()
{
if (MainWP_Utility::isAdmin()) {
global $current_user;
delete_user_option($current_user->ID, 'screen_layout_toplevel_page_mainwp_tab');
$this->dashBoard = add_menu_page('MainWP', 'MainWP', 'read', 'mainwp_tab', array($this, 'on_show_page'), plugins_url('images/mainwpicon.png', dirname(__FILE__)), '2.00001');
if (mainwp_current_user_can('dashboard', 'access_global_dashboard')) {
add_submenu_page('mainwp_tab', 'MainWP', __('Dashboard', 'mainwp'), 'read', 'mainwp_tab', array($this, 'on_show_page'));
}
$val = get_user_option('screen_layout_' . $this->dashBoard);
if (!MainWP_Utility::ctype_digit($val)) {
update_user_option($current_user->ID, 'screen_layout_' . $this->dashBoard, 2, true);
}
add_action('load-' . $this->dashBoard, array(&$this, 'on_load_page'));
}
// else
// {
// $this->dashBoard = add_menu_page('MainWP', 'MainWP', 'read', 'mainwp_tab', array($this, 'require_registration'), plugins_url('images/mainwpicon.png', dirname(__FILE__)), '2.0001');
// }
}
示例13: autosub_activate
function autosub_activate()
{
$all_users = get_users('orderby=ID');
# Save a backup of everyone's subscription preferences so we can restore it if
# we decide not to use the plugin.
require_once ABSPATH . 'wp-admin/includes/upgrade.php';
global $wpdb;
$table_name = $wpdb->prefix . "autosub";
# Create table for backups if it doesn't already exist
$charset_collate = $wpdb->get_charset_collate();
$sql = "CREATE TABLE IF NOT EXISTS {$table_name} (\n id mediumint(9) NOT NULL AUTO_INCREMENT,\n user_id mediumint(9) NOT NULL,\n type varchar(20) NOT NULL,\n subscriptions longtext,\n UNIQUE KEY id (id)\n ) {$charset_collate};";
dbDelta($sql);
# Delete old backups if they exist
$wpdb->delete($table_name, array('type' => 'topic'));
$wpdb->delete($table_name, array('type' => 'forum'));
# Store backups of subscriptions
foreach ($all_users as $user) {
$user_id = $user->ID;
# Backup topic subscriptions
$topic_subscriptions = get_user_option('_bbp_subscriptions', $user_id);
if (strlen($topic_subscriptions) <= 0) {
continue;
}
$sql = "INSERT INTO {$table_name}\n (user_id, type, subscriptions)\n VALUES (\n {$user_id},\n 'topic',\n '{$topic_subscriptions}'\n );";
dbDelta($sql);
# Backup forum subscriptions
$forum_subscriptions = get_user_option('_bbp_forum_subscriptions', $user_id);
if (strlen($forum_subscriptions) <= 0) {
continue;
}
$sql = "INSERT INTO {$table_name}\n (user_id, type, subscriptions)\n VALUES (\n {$user_id},\n 'forum',\n '{$forum_subscriptions}'\n );";
dbDelta($sql);
}
# Delete subscriptions because they would otherwise turn into unsubscriptions.
foreach ($all_users as $user) {
if (!autosub_is_user_an_exception($user->ID)) {
delete_user_option($user->ID, '_bbp_subscriptions');
delete_user_option($user->ID, '_bbp_forum_subscriptions');
}
}
}
示例14: wpmu_create_user
/**
* Create a user.
*
* This function runs when a user self-registers as well as when
* a Super Admin creates a new user. Hook to 'wpmu_new_user' for events
* that should affect all new users, but only on Multisite (otherwise
* use 'user_register').
*
* @since MU
*
* @param string $user_name The new user's login name.
* @param string $password The new user's password.
* @param string $email The new user's email address.
* @return int|false Returns false on failure, or int $user_id on success
*/
function wpmu_create_user($user_name, $password, $email)
{
$user_name = preg_replace('/\\s+/', '', sanitize_user($user_name, true));
$user_id = wp_create_user($user_name, $password, $email);
if (is_wp_error($user_id)) {
return false;
}
// Newly created users have no roles or caps until they are added to a blog.
delete_user_option($user_id, 'capabilities');
delete_user_option($user_id, 'user_level');
/**
* Fires immediately after a new user is created.
*
* @since MU
*
* @param int $user_id User ID.
*/
do_action('wpmu_new_user', $user_id);
return $user_id;
}
示例15: uninstall_plugin
private static function uninstall_plugin()
{
global $wpdb;
$cf = WpssoConfig::get_config();
$slug = $cf['plugin'][$cf['lca']]['slug'];
$options = get_option($cf['lca'] . '_options');
if (empty($options['plugin_preserve'])) {
delete_option($cf['lca'] . '_options');
delete_post_meta_by_key('_' . $cf['lca'] . '_meta');
WpssoUser::delete_metabox_prefs();
}
// delete update related options
delete_option('external_updates-' . $slug);
delete_option($cf['lca'] . '_umsg');
delete_option($cf['lca'] . '_utime');
// delete stored admin notices
foreach (array('nag', 'err', 'inf') as $type) {
$msg_opt = $cf['lca'] . '_notices_' . $type;
delete_option($msg_opt);
foreach (get_users(array('meta_key' => $msg_opt)) as $user) {
delete_user_option($user->ID, $msg_opt);
}
}
// delete transients
$dbquery = 'SELECT option_name FROM ' . $wpdb->options . ' WHERE option_name LIKE \'_transient_timeout_' . $cf['lca'] . '_%\';';
$expired = $wpdb->get_col($dbquery);
foreach ($expired as $transient) {
$key = str_replace('_transient_timeout_', '', $transient);
if (!empty($key)) {
delete_transient($key);
}
}
}