本文整理汇总了PHP中WP_User::remove_cap方法的典型用法代码示例。如果您正苦于以下问题:PHP WP_User::remove_cap方法的具体用法?PHP WP_User::remove_cap怎么用?PHP WP_User::remove_cap使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类WP_User
的用法示例。
在下文中一共展示了WP_User::remove_cap方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: UpdateUserFields
public function UpdateUserFields($user_id)
{
if (current_user_can('edit_user', $user_id)) {
if (current_user_can('LearningRegistryPublisherManage', $user_id)) {
$user = new WP_User($user_id);
$LearningRegistryPublisher = new LearningRegistryPublisher();
foreach ($LearningRegistryPublisher->AdministratorCapabilities as $capability) {
$user->remove_cap($capability);
}
if (isset($_POST['LearningRegistryPublisherManage'])) {
$user->add_cap('LearningRegistryPublisherManage');
foreach ($LearningRegistryPublisher->AdministratorCapabilities as $capability) {
$user->add_cap($capability);
}
} else {
$user->remove_cap('LearningRegistryPublisherManage');
}
if (isset($_POST['LearningRegistryPublisherSchema'])) {
$user->add_cap('LearningRegistryPublisherSchema');
foreach ($LearningRegistryPublisher->SchemaCapabilities as $capability) {
$user->add_cap($capability);
}
} else {
$user->remove_cap('LearningRegistryPublisherSchema');
foreach ($LearningRegistryPublisher->SchemaCapabilities as $capability) {
$user->remove_cap($capability);
}
}
if (isset($_POST['LearningRegistryPublisherKeys'])) {
$user->add_cap('LearningRegistryPublisherKeys');
foreach ($LearningRegistryPublisher->KeyCapabilities as $capability) {
$user->add_cap($capability);
}
} else {
$user->remove_cap('LearningRegistryPublisherKeys');
foreach ($LearningRegistryPublisher->KeyCapabilities as $capability) {
$user->remove_cap($capability);
}
}
if (isset($_POST['LearningRegistryPublisherHistory'])) {
$user->add_cap('LearningRegistryPublisherHistory');
} else {
$user->remove_cap('LearningRegistryPublisherHistory');
}
if (isset($_POST['LearningRegistryPublisherOverrideDefaults'])) {
$user->add_cap('LearningRegistryPublisherOverrideDefaults');
} else {
$user->remove_cap('LearningRegistryPublisherOverrideDefaults');
}
if (isset($_POST['LearningRegistryPublisherManageDocument'])) {
$user->add_cap('LearningRegistryPublisherManageDocument');
} else {
$user->remove_cap('LearningRegistryPublisherManageDocument');
}
}
}
}
开发者ID:navnorth,项目名称:wp-learning-registry-publisher,代码行数:57,代码来源:learning-registry-publisher-user-fields.php
示例2: remove_network_snippets_cap
/**
* Remove the multisite capabilities from a user
*
* @since 2.0
* @param integer $user_id The ID of the user to remove the cap from
*/
function remove_network_snippets_cap($user_id)
{
/* Get the user from the ID */
$user = new WP_User($user_id);
/* Remove the capability */
$user->remove_cap(apply_filters('code_snippets_network_cap', 'manage_network_snippets'));
}
示例3: save
public function save($userId)
{
if (!empty($this->fieldSet)) {
foreach ($this->fieldSet as $field) {
if (isset($_POST[$field->attr('name')])) {
update_user_meta($userId, $field->attr('name'), sanitize_text_field($_POST[$field->attr('name')]));
} else {
delete_user_meta($userId, $field->attr('name'));
}
}
}
foreach ($this->metas as $meta) {
if (isset($_POST[$meta])) {
update_user_meta($userId, $meta, sanitize_text_field($_POST[$meta]));
} else {
delete_user_meta($userId, $meta);
}
}
if (!empty($this->caps)) {
$user = new \WP_User($userId);
foreach ($this->caps as $cap) {
if (!empty($_POST[$cap])) {
$user->add_cap($cap);
} else {
$user->remove_cap($cap);
}
}
}
}
示例4: wpec_members_remove_capability_from_users
function wpec_members_remove_capability_from_users($capability)
{
$users = new WP_User_Search('', '', $capability);
$user_ids = $users->results;
foreach ($user_ids as $user_id) {
$user = new WP_User($user_id);
$user->remove_cap($capability);
$members_lengths = get_user_meta($user_id, '_subscription_ends', true);
$subscription_lengths = get_user_meta($user_id, '_subscription_length', true);
$subscription_starts = get_user_meta($user_id, '_subscription_starts', true);
unset($subscription_lengths[$capability]);
unset($members_lengths[$capability]);
unset($subscription_starts[$capability]);
//if the array is now empty then we know they only had one sub
if (empty($members_lengths)) {
delete_user_meta($user_id, '_subscription_starts');
delete_user_meta($user_id, '_subscription_ends');
delete_user_meta($user_id, '_subscription_length');
delete_user_meta($user_id, '_has_current_subscription');
} else {
update_user_meta($user_id, '_subscription_starts', $subscription_starts);
update_user_meta($user_id, '_subscription_ends', $members_lengths);
update_user_meta($user_id, '_subscription_length', $subscription_lengths);
}
}
}
示例5: ccap_user_update
/**
* Update users custom capabilities
*
* @see https://github.com/websharks/s2member/blob/150311/s2member/includes/classes/paypal-notify-in-subscr-modify-w-level.inc.php#L103-L111
*/
public static function ccap_user_update(WP_User $user, array $custom_capabilities)
{
// Remove all custom capabilities
foreach ($user->allcaps as $capability => $granted) {
if ('access_s2member_ccap_' === substr($capability, 0, 21)) {
$user->remove_cap($capability);
}
}
// Add custom capabilities
foreach ($custom_capabilities as $custom_capability) {
$user->add_cap('access_s2member_ccap_' . $custom_capability);
}
}
示例6: foreach
/**
* remove_course_caps( $user_id )
*
* Adds course capabilities to new $user_id
*
* @param Int $user_id ID of the user capabilities to be removed from
*/
function remove_course_caps($user_id)
{
//Treat super admins
if (is_super_admin($user_id)) {
return;
}
$user = new WP_User($user_id);
foreach ($this->caps as $c) {
if ($user->has_cap($c)) {
$user->remove_cap($c);
}
}
}
示例7: import_users
//.........这里部分代码省略.........
continue;
// Skip this line.
}
$_wp_update_user = array('ID' => $_user_id);
foreach ($user_keys as $_user_key) {
if (($_user_data_key = array_search($_user_key, $headers)) !== FALSE && isset($_csv_data[$_user_data_key])) {
$_wp_update_user[$_user_key] = $_csv_data[$_user_data_key];
}
}
unset($_user_key, $_user_data_key);
// Housekeeping.
if (!wp_update_user(wp_slash($_wp_update_user))) {
$errors[] = 'Line #' . $line . '. Post insertion update failed on User ID# <code>' . esc_html($_user_id) . '</code>. Unknown error, please try again.';
continue;
// Skip this line.
}
unset($_wp_update_user);
// Housekeeping.
if (is_multisite()) {
// New Users on a Multisite Network need this too.
update_user_meta($_user_id, 's2member_originating_blog', $current_blog->blog_id);
}
clean_user_cache($_user_id);
wp_cache_delete($_user_id, 'user_meta');
$_user = new WP_User($_user_id);
$imported = $imported + 1;
}
if ($_user_role) {
$_user->set_role($_user_role);
}
if ($_user_ccaps) {
foreach ($_user->allcaps as $_cap => $_cap_enabled) {
if (preg_match('/^access_s2member_ccap_/', $_cap)) {
$_user->remove_cap($_cap);
}
}
unset($_cap, $_cap_enabled);
// Housekeeping.
if (preg_replace('/^-all[' . "\r\n\t" . '\\s;,]*/', '', str_replace('+', '', $_user_ccaps))) {
foreach (preg_split('/[' . "\r\n\t" . '\\s;,]+/', preg_replace('/^-all[' . "\r\n\t" . '\\s;,]*/', '', str_replace('+', '', $_user_ccaps))) as $_ccap) {
if (strlen($_ccap = trim(strtolower(preg_replace('/[^a-z_0-9]/i', '', $_ccap))))) {
$_user->add_cap('access_s2member_ccap_' . $_ccap);
}
}
}
}
$_user_custom_fields = get_user_option('s2member_custom_fields', $_user_id);
$_user_custom_fields = is_array($_user_custom_fields) ? $_user_custom_fields : array();
foreach ($headers as $_index => $_header) {
if (strpos($_header, 'meta_key__') === 0) {
if (isset($_csv_data[$_index])) {
$_new_meta_value = $_csv_data[$_index];
$_user_meta_key = substr($_header, strlen('meta_key__'));
if ($_user_meta_key === $wpdb->prefix . 'capabilities' && ($_user_role || $_user_ccaps)) {
continue;
}
// Already handled via `role` and `ccaps`.
if ($_user_meta_key === $wpdb->prefix . 'capabilities' && stripos($_new_meta_value, 'administrator') !== FALSE) {
continue;
}
// Do not allow this for security purposes.
if (is_multisite() && c_ws_plugin__s2member_utils_conds::is_multisite_farm() && !is_main_site()) {
if (strpos($_user_meta_key, $wpdb->prefix) !== 0 && !in_array($_user_meta_key, array('first_name', 'last_name', 'nickname', 'description'), TRUE)) {
continue;
}
}
示例8: wplc_ma_set_user_as_agent
function wplc_ma_set_user_as_agent($user_id)
{
if (!current_user_can('edit_user', $user_id)) {
return false;
}
if (isset($_POST['wplc_ma_agent'])) {
update_user_meta($user_id, 'wplc_ma_agent', $_POST['wplc_ma_agent']);
} else {
delete_user_meta($user_id, 'wplc_ma_agent');
}
if ($_POST['wplc_ma_agent'] == '1') {
$wplc_ma_user = new WP_User($user_id);
$wplc_ma_user->add_cap('wplc_ma_agent');
update_user_meta($user_id, "wplc_chat_agent_online", time());
} else {
$wplc_ma_user = new WP_User($user_id);
$wplc_ma_user->remove_cap('wplc_ma_agent');
delete_user_meta($user_id, "wplc_ma_agent");
delete_user_meta($user_id, "wplc_chat_agent_online");
}
}
示例9: array
/**
* On activation, include the installer and run it.
*
* @access public
* @return void
*/
function wcmp_plugins_loaded()
{
global $WCMp, $wpdb;
//delete_option('dc_product_vendor_plugin_db_version');
$previous_plugin_version = get_option('dc_product_vendor_plugin_db_version');
if (!$previous_plugin_version || $previous_plugin_version < $WCMp->version) {
$prev_general = get_option('dc_general_settings_name');
$prev_product = get_option('dc_product_settings_name');
$prev_capability = get_option('dc_capabilities_settings_name');
$prev_pages = get_option('dc_pages_settings_name');
$prev_payment = get_option('dc_payment_settings_name');
$new_general = $new_product = $new_capability = $new_pages = $new_payment = $new_frontend = array();
$new_payment = $prev_payment;
if (!empty($prev_general)) {
if (isset($prev_general['enable_registration'])) {
$new_general['enable_registration'] = 'Enable';
}
if (isset($prev_general['approve_vendor_manually'])) {
$new_general['approve_vendor_manually'] = 'Enable';
}
if (isset($prev_general['notify_configure_vendor_store'])) {
$new_general['notify_configure_vendor_store'] = $prev_general['notify_configure_vendor_store'];
}
if (isset($prev_general['default_commission'])) {
$new_payment['default_commission'] = $prev_general['default_commission'];
}
if (isset($prev_general['commission_type'])) {
$new_payment['commission_type'] = $prev_general['commission_type'];
}
if (isset($prev_general['commission_include_coupon'])) {
$new_payment['commission_include_coupon'] = $prev_general['commission_include_coupon'];
}
if (isset($prev_general['sold_by_catalog'])) {
$new_frontend['sold_by_catalog'] = $prev_general['sold_by_catalog'];
}
if (isset($prev_general['catalog_colorpicker'])) {
$new_frontend['catalog_colorpicker'] = $prev_general['catalog_colorpicker'];
}
if (isset($prev_general['catalog_hover_colorpicker'])) {
$new_frontend['catalog_hover_colorpicker'] = $prev_general['catalog_hover_colorpicker'];
}
if (isset($prev_general['sold_by_cart_and_checkout'])) {
$new_frontend['sold_by_cart_and_checkout'] = $prev_general['sold_by_cart_and_checkout'];
}
if (isset($prev_general['sold_by_text'])) {
$new_frontend['sold_by_text'] = $prev_general['sold_by_text'];
}
if (isset($prev_general['block_vendor_desc'])) {
$new_frontend['block_vendor_desc'] = $prev_general['block_vendor_desc'];
}
}
if (!empty($prev_capability)) {
$new_capability = $prev_capability;
if (isset($new_capability['give_tax'])) {
$new_payment['give_tax'] = $new_capability['give_tax'];
unset($new_capability['give_tax']);
}
if (isset($new_capability['give_shipping'])) {
$new_payment['give_shipping'] = $new_capability['give_shipping'];
unset($new_capability['give_shipping']);
}
}
if (!empty($prev_product)) {
update_option('wcmp_product_settings_name', $prev_product);
}
if (!empty($prev_pages)) {
update_option('wcmp_pages_settings_name', $prev_pages);
}
if (!empty($new_general)) {
update_option('wcmp_general_settings_name', $new_general);
}
if (!empty($new_capability)) {
update_option('wcmp_capabilities_settings_name', $new_capability);
}
if (!empty($new_payment)) {
update_option('wcmp_payment_settings_name', $new_payment);
}
if (!empty($new_frontend)) {
update_option('wcmp_frontend_settings_name', $new_frontend);
}
delete_option('dc_general_settings_name');
delete_option('dc_product_settings_name');
delete_option('dc_capabilities_settings_name');
delete_option('dc_payment_settings_name');
delete_option('dc_pages_settings_name');
$vendors = get_wcmp_vendors();
if (!empty($vendors)) {
foreach ($vendors as $vendor) {
$vendorusers = new WP_User($vendor->id);
$vendorusers->remove_cap('manage_woocommerce');
$vendor_products = $vendor->get_products();
if (!empty($vendor_products)) {
foreach ($vendor_products as $vendor_product) {
wp_update_post(array('ID' => $vendor_product->ID, 'post_author' => $vendor->id));
//.........这里部分代码省略.........
示例10: cp
/**
* s2Member's PayPal Auto-Return/PDT handler (inner processing routine).
*
* @package s2Member\PayPal
* @since 110720
*
* @param array $vars Required. An array of defined variables passed by {@link s2Member\PayPal\c_ws_plugin__s2member_paypal_return_in::paypal_return()}.
*
* @return array|bool The original ``$paypal`` array passed in (extracted) from ``$vars``, or false when conditions do NOT apply.
*/
public static function cp($vars = array())
{
extract($vars, EXTR_OVERWRITE | EXTR_REFS);
if (!empty($paypal['txn_type']) && preg_match('/^web_accept$/i', $paypal['txn_type']) && (!empty($paypal['item_number']) && preg_match($GLOBALS['WS_PLUGIN__']['s2member']['c']['membership_item_number_wo_level_regex'], $paypal['item_number'])) && (empty($paypal['payment_status']) || empty($payment_status_issues) || !preg_match($payment_status_issues, $paypal['payment_status'])) && !empty($paypal['txn_id']) && !empty($paypal['payer_email']) && (!empty($paypal['txn_baid']) || ($paypal['txn_baid'] = $paypal['txn_id'])) && (!empty($paypal['txn_cid']) || ($paypal['txn_cid'] = $paypal['txn_id']))) {
foreach (array_keys(get_defined_vars()) as $__v) {
$__refs[$__v] =& ${$__v};
}
do_action('ws_plugin__s2member_during_paypal_return_before_new_ccaps', get_defined_vars());
unset($__refs, $__v);
if (!get_transient($transient_rtn = 's2m_rtn_' . md5('s2member_transient_' . $_paypal_s)) && set_transient($transient_rtn, time(), 31556926 * 10)) {
$paypal['s2member_log'][] = 's2Member `txn_type` identified as ( `web_accept` ) w/ update vars for Capabilities w/o Level.';
list($paypal['level'], $paypal['ccaps'], $paypal['eotper']) = preg_split('/\\:/', $paypal['item_number'], 3);
$paypal['ip'] = preg_match('/ip address/i', $paypal['option_name2']) && $paypal['option_selection2'] ? $paypal['option_selection2'] : '';
$paypal['ip'] = !$paypal['ip'] && preg_match('/^[a-z0-9]+~[0-9\\.]+$/i', $paypal['invoice']) ? preg_replace('/^[a-z0-9]+~/i', '', $paypal['invoice']) : $paypal['ip'];
$paypal['ip'] = !$paypal['ip'] && $_SERVER['REMOTE_ADDR'] ? $_SERVER['REMOTE_ADDR'] : $paypal['ip'];
$paypal['currency'] = strtoupper($paypal['mc_currency']);
// Normalize input currency.
$paypal['currency_symbol'] = c_ws_plugin__s2member_utils_cur::symbol($paypal['currency']);
if (preg_match('/(referenc|associat|updat|upgrad)/i', $paypal['option_name1']) && $paypal['option_selection1']) {
if (($user_id = c_ws_plugin__s2member_utils_users::get_user_id_with($paypal['txn_id'], $paypal['option_selection1'])) && is_object($user = new WP_User($user_id)) && $user->ID) {
if (!$user->has_cap('administrator')) {
$processing = $during = TRUE;
// Yes, we ARE processing this.
$fields = get_user_option('s2member_custom_fields', $user_id);
// These will be needed in the routines below.
$user_reg_ip = get_user_option('s2member_registration_ip', $user_id);
// Original IP during Registration.
$user_reg_ip = $paypal['ip'] = $user_reg_ip ? $user_reg_ip : $paypal['ip'];
// Now merge conditionally.
if (is_multisite() && !is_user_member_of_blog($user_id)) {
add_existing_user_to_blog(array('user_id' => $user_id, 'role' => get_option('default_role')));
$user = new WP_User($user_id);
}
if ($paypal['ccaps'] && preg_match('/^-all/', str_replace('+', '', $paypal['ccaps']))) {
foreach ($user->allcaps as $cap => $cap_enabled) {
if (preg_match('/^access_s2member_ccap_/', $cap)) {
$user->remove_cap($ccap = $cap);
}
}
}
if ($paypal['ccaps'] && preg_replace('/^-all[' . "\r\n\t" . '\\s;,]*/', '', str_replace('+', '', $paypal['ccaps']))) {
foreach (preg_split('/[' . "\r\n\t" . '\\s;,]+/', preg_replace('/^-all[' . "\r\n\t" . '\\s;,]*/', '', str_replace('+', '', $paypal['ccaps']))) as $ccap) {
if (strlen($ccap = trim(strtolower(preg_replace('/[^a-z_0-9]/i', '', $ccap))))) {
$user->add_cap('access_s2member_ccap_' . $ccap);
}
}
}
if (!get_user_option('s2member_registration_ip', $user_id)) {
update_user_option($user_id, 's2member_registration_ip', $paypal['ip']);
}
$paypal['s2member_log'][] = 's2Member Custom Capabilities updated w/ advanced update routines.';
setcookie('s2member_tracking', $s2member_tracking = c_ws_plugin__s2member_utils_encryption::encrypt($paypal['txn_id']), time() + 31556926, COOKIEPATH, COOKIE_DOMAIN) . setcookie('s2member_tracking', $s2member_tracking, time() + 31556926, SITECOOKIEPATH, COOKIE_DOMAIN) . ($_COOKIE['s2member_tracking'] = $s2member_tracking);
$paypal['s2member_log'][] = 'Transient Tracking Cookie set on ( `web_accept` ) w/ update vars for Capabilities w/o Level.';
if ($processing && ($code = $GLOBALS['WS_PLUGIN__']['s2member']['o']['ccap_tracking_codes']) && is_array($cv = preg_split('/\\|/', $paypal['custom']))) {
if (($code = preg_replace('/%%cv([0-9]+)%%/ei', 'trim(@$cv[$1])', $code)) && ($code = preg_replace('/%%(?:subscr|txn)_id%%/i', c_ws_plugin__s2member_utils_strings::esc_refs($paypal['txn_id']), $code))) {
if (($code = preg_replace('/%%(?:subscr|txn)_baid%%/i', c_ws_plugin__s2member_utils_strings::esc_refs($paypal['txn_baid']), $code)) && ($code = preg_replace('/%%(?:subscr|txn)_cid%%/i', c_ws_plugin__s2member_utils_strings::esc_refs($paypal['txn_cid']), $code))) {
if (($code = preg_replace('/%%currency%%/i', c_ws_plugin__s2member_utils_strings::esc_refs($paypal['currency']), $code)) && ($code = preg_replace('/%%currency_symbol%%/i', c_ws_plugin__s2member_utils_strings::esc_refs($paypal['currency_symbol']), $code))) {
if (($code = preg_replace('/%%amount%%/i', c_ws_plugin__s2member_utils_strings::esc_refs($paypal['mc_gross']), $code)) && ($code = preg_replace('/%%txn_id%%/i', c_ws_plugin__s2member_utils_strings::esc_refs($paypal['txn_id']), $code))) {
if (($code = preg_replace('/%%item_number%%/i', c_ws_plugin__s2member_utils_strings::esc_refs($paypal['item_number']), $code)) && ($code = preg_replace('/%%item_name%%/i', c_ws_plugin__s2member_utils_strings::esc_refs($paypal['item_name']), $code))) {
if (($code = preg_replace('/%%first_name%%/i', c_ws_plugin__s2member_utils_strings::esc_refs($paypal['first_name']), $code)) && ($code = preg_replace('/%%last_name%%/i', c_ws_plugin__s2member_utils_strings::esc_refs($paypal['last_name']), $code))) {
if ($code = preg_replace('/%%full_name%%/i', c_ws_plugin__s2member_utils_strings::esc_refs(trim($paypal['first_name'] . ' ' . $paypal['last_name'])), $code)) {
if ($code = preg_replace('/%%payer_email%%/i', c_ws_plugin__s2member_utils_strings::esc_refs($paypal['payer_email']), $code)) {
if (($code = preg_replace('/%%user_first_name%%/i', c_ws_plugin__s2member_utils_strings::esc_refs($user->first_name), $code)) && ($code = preg_replace('/%%user_last_name%%/i', c_ws_plugin__s2member_utils_strings::esc_refs($user->last_name), $code))) {
if ($code = preg_replace('/%%user_full_name%%/i', c_ws_plugin__s2member_utils_strings::esc_refs(trim($user->first_name . ' ' . $user->last_name)), $code)) {
if ($code = preg_replace('/%%user_email%%/i', c_ws_plugin__s2member_utils_strings::esc_refs($user->user_email), $code)) {
if ($code = preg_replace('/%%user_login%%/i', c_ws_plugin__s2member_utils_strings::esc_refs($user->user_login), $code)) {
if ($code = preg_replace('/%%user_ip%%/i', c_ws_plugin__s2member_utils_strings::esc_refs($user_reg_ip), $code)) {
if ($code = preg_replace('/%%user_id%%/i', c_ws_plugin__s2member_utils_strings::esc_refs($user_id), $code)) {
if (is_array($fields) && !empty($fields)) {
foreach ($fields as $var => $val) {
if (!($code = preg_replace('/%%' . preg_quote($var, '/') . '%%/i', c_ws_plugin__s2member_utils_strings::esc_refs(maybe_serialize($val)), $code))) {
break;
}
}
}
if ($code = trim(preg_replace('/%%(.+?)%%/i', '', $code))) {
$paypal['s2member_log'][] = 'Storing Payment Tracking Codes into a Transient Queue. These will be processed on-site.';
set_transient('s2m_' . md5('s2member_transient_ccap_tracking_codes_' . $paypal['txn_id']), $code, 43200);
}
}
}
}
}
}
}
}
}
}
}
}
//.........这里部分代码省略.........
示例11: disable_all_caps
public function disable_all_caps()
{
global $wp_roles;
if (!isset($wp_roles) || !is_object($wp_roles)) {
$wp_roles = new WP_Roles();
}
$ddl_capabilities = array_keys(self::ddl_get_capabilities());
foreach ($ddl_capabilities as $cap) {
foreach (array_keys($wp_roles->roles) as $role) {
$wp_roles->remove_cap($role, $cap);
}
}
//Remove caps for all Super Admins
$super_admins = get_super_admins();
foreach ($super_admins as $admin) {
$user = new WP_User($admin);
for ($i = 0, $caps_limit = count($ddl_capabilities); $i < $caps_limit; $i++) {
$user->remove_cap($ddl_capabilities[$i]);
}
}
$this->ddl_users_settings->update_options('updated_profiles', false, true);
}
示例12: import_users
//.........这里部分代码省略.........
$paid_registration_times = !$paid_registration_times || !is_array($paid_registration_times) ? array() : $paid_registration_times;
$user_details = compact("ID", "user_login", "user_pass", "first_name", "last_name", "display_name", "user_email", "user_url", "role", "user_registered");
if (empty($user_details["user_pass"])) {
// If there was NO Password given.
unset($user_details["user_pass"]);
}
// Unset the Password array element.
if ($ID) {
if (is_object($user = new WP_User($ID)) && $user->ID) {
if (!is_multisite() || is_user_member_of_blog($ID)) {
if ((!is_multisite() || !is_super_admin($ID)) && !$user->has_cap("administrator")) {
if (strtolower($role) !== "administrator") {
if ($user_email && is_email($user_email)) {
if ($user_login) {
if (validate_username($user_login)) {
if (($_same_email = strtolower($user_email) === strtolower($user->user_email)) || !email_exists($user_email)) {
if (($_same_login = strtolower($user_login) === strtolower($user->user_login)) || !username_exists($user_login)) {
if (!is_multisite() || $_same_email && $_same_login || ($_ = wpmu_validate_user_signup($user_login, $user_email)) && (!is_wp_error($_["errors"]) || !$_["errors"]->get_error_code())) {
if (is_multisite() && c_ws_plugin__s2member_utils_conds::is_multisite_farm() && !is_main_site()) {
unset($user_details["user_login"], $user_details["user_pass"]);
}
if ($user_id = wp_update_user($user_details)) {
$user = new WP_User($ID);
// Refresh object value.
update_user_option($user_id, "s2member_custom", $custom);
update_user_option($user_id, "s2member_subscr_id", $subscr_id);
update_user_option($user_id, "s2member_subscr_gateway", $subscr_gateway);
update_user_option($user_id, "s2member_auto_eot_time", $auto_eot_time);
update_user_option($user_id, "s2member_paid_registration_times", $paid_registration_times);
update_user_option($user_id, "s2member_last_payment_time", $last_payment_time);
update_user_option($user_id, "s2member_custom_fields", $custom_fields);
foreach ($user->allcaps as $cap => $cap_enabled) {
if (preg_match("/^access_s2member_ccap_/", $cap)) {
$user->remove_cap($ccap = $cap);
}
}
if ($custom_capabilities && preg_replace("/^-all[\r\n\t\\s;,]*/", "", str_replace("+", "", $custom_capabilities))) {
foreach (preg_split("/[\r\n\t\\s;,]+/", preg_replace("/^-all[\r\n\t\\s;,]*/", "", str_replace("+", "", $custom_capabilities))) as $ccap) {
if (strlen($ccap = trim(strtolower(preg_replace("/[^a-z_0-9]/i", "", $ccap))))) {
$user->add_cap("access_s2member_ccap_" . $ccap);
}
}
}
$imported = $imported + 1;
} else {
$errors[] = "Line #" . $line . ". User ID# <code>" . $ID . "</code> could NOT be updated. Unknown error, please try again.";
}
} else {
$errors[] = "Line #" . $line . ". Network. The Username and/or Email (<code>" . esc_html($user_login) . "</code> / <code>" . esc_html($user_email) . "</code>) are in conflict w/ Network rules.";
}
} else {
$errors[] = "Line #" . $line . ". Conflicting. The Username (<code>" . esc_html($user_login) . "</code>), already exists.";
}
} else {
$errors[] = "Line #" . $line . ". Conflicting. The Email address (<code>" . esc_html($user_email) . "</code>), already exists.";
}
} else {
$errors[] = "Line #" . $line . ". Invalid Username (<code>" . esc_html($user_login) . "</code>). Lowercase alphanumerics are required.";
}
} else {
$errors[] = "Line #" . $line . ". Missing Username; please try again.";
}
// We have two separate errors for Usernames. This provides clarity.
} else {
$errors[] = "Line #" . $line . ". Missing or invalid Email address (<code>" . esc_html($user_email) . "</code>); please try again.";
}
示例13: spa_deactivate_plugin
function spa_deactivate_plugin()
{
$uninstall = sp_get_option('sfuninstall');
if ($uninstall) {
# uninstall - remove all data
# remove any admin capabilities
$admins = spdb_table(SFMEMBERS, 'admin=1');
foreach ($admins as $admin) {
$user = new WP_User($admin->user_id);
$user->remove_cap('SPF Manage Options');
$user->remove_cap('SPF Manage Forums');
$user->remove_cap('SPF Manage User Groups');
$user->remove_cap('SPF Manage Permissions');
$user->remove_cap('SPF Manage Tags');
$user->remove_cap('SPF Manage Components');
$user->remove_cap('SPF Manage Admins');
$user->remove_cap('SPF Manage Profiles');
$user->remove_cap('SPF Manage Users');
$user->remove_cap('SPF Manage Toolbox');
$user->remove_cap('SPF Manage Plugins');
$user->remove_cap('SPF Manage Themes');
$user->remove_cap('SPF Manage Integration');
$user->remove_cap('SPF Manage Configuration');
# no longer used but some may still have it
}
# remove any installed tables
$tables = sp_get_option('installed_tables');
if ($tables) {
foreach ($tables as $table) {
spdb_query("DROP TABLE IF EXISTS {$table}");
}
}
# since we have removed our tables, need to turn off error logging to prevent onslaught of errors
global $spGlobals;
$spGlobals['record-errors'] = false;
# Remove the Page record
$sfpage = sp_get_option('sfpage');
if (!empty($sfpage)) {
spdb_query('DELETE FROM ' . SFWPPOSTS . ' WHERE ID=' . sp_get_option('sfpage'));
}
# remove widget data
delete_option('widget_spf');
delete_option('widget_sforum');
# remove any wp options we might have set
delete_option('sfInstallID');
delete_option('sp_storage1');
delete_option('sp_storage2');
# Now remove user meta data
$optionlist = array('sfadmin', 'location', 'msn', 'skype', 'icq', 'facebook', 'myspace', 'twitter', 'linkedin', 'youtube', 'googleplus', 'sfuse_quicktags', 'signature', 'sigimage');
foreach ($optionlist as $option) {
spdb_query('DELETE FROM ' . SFUSERMETA . " WHERE meta_key='{$option}';");
}
# send our uninstall action
do_action('sph_uninstalled', $admins);
# remove storage locations if so directed
if (sp_get_option('removestorage')) {
# let's remove our directories and storage
global $spPaths;
if (!empty($spPaths)) {
foreach ($spPaths as $storage => $path) {
# lets not remove plugins and themes
if ($storage != 'plugins' && $storage != 'themes') {
sp_remove_dir(SF_STORE_DIR . '/' . $path);
}
}
}
# remove the languages folder if it exists
# note the sp-resources dire may not exist - but its our default. if user creates other parent dir for languages, we wont know about it
sp_remove_dir(SF_STORE_DIR . '/sp-resources/forum-language');
}
}
# remove the combined css and js cache files
sp_clear_combined_css('all');
sp_clear_combined_css('mobile');
sp_clear_combined_css('tablet');
# remove cron jobs for deactivaton or uninstall
wp_clear_scheduled_hook('spf_cron_pm');
# left here for 5.0 who doesnt upgrade
wp_clear_scheduled_hook('spf_cron_sitemap');
# left here for 5.0 who doesnt upgrade
wp_clear_scheduled_hook('sph_cron_user');
wp_clear_scheduled_hook('sph_transient_cleanup_cron');
wp_clear_scheduled_hook('sph_stats_cron');
wp_clear_scheduled_hook('sph_news_cron');
# send deactivated action
if (!$uninstall) {
do_action('sph_deactivated');
}
}
示例14: cp
/**
* s2Member's PayPal IPN handler (inner processing routine).
*
* @package s2Member\PayPal
* @since 110815
*
* @param array $vars Required. An array of defined variables passed by {@link s2Member\PayPal\c_ws_plugin__s2member_paypal_notify_in::paypal_notify()}.
*
* @return array|bool The original ``$paypal`` array passed in (extracted) from ``$vars``, or false when conditions do NOT apply.
*/
public static function cp($vars = array())
{
extract($vars, EXTR_OVERWRITE | EXTR_REFS);
// Extract all vars passed in from: ``c_ws_plugin__s2member_paypal_notify_in::paypal_notify()``.
if (!empty($paypal['txn_type']) && preg_match('/^web_accept$/i', $paypal['txn_type']) && (!empty($paypal['item_number']) && preg_match($GLOBALS['WS_PLUGIN__']['s2member']['c']['membership_item_number_wo_level_regex'], $paypal['item_number'])) && (empty($paypal['payment_status']) || empty($payment_status_issues) || !preg_match($payment_status_issues, $paypal['payment_status'])) && !empty($paypal['txn_id']) && !empty($paypal['payer_email']) && (!empty($paypal['txn_baid']) || ($paypal['txn_baid'] = $paypal['txn_id'])) && (!empty($paypal['txn_cid']) || ($paypal['txn_cid'] = $paypal['txn_id']))) {
foreach (array_keys(get_defined_vars()) as $__v) {
$__refs[$__v] =& ${$__v};
}
do_action('ws_plugin__s2member_during_paypal_notify_before_new_ccaps', get_defined_vars());
unset($__refs, $__v);
if (!get_transient($transient_ipn = 's2m_ipn_' . md5('s2member_transient_' . $_paypal_s)) && set_transient($transient_ipn, time(), 31556926 * 10)) {
$paypal['s2member_log'][] = 's2Member `txn_type` identified as ( `web_accept` ) w/ update vars for Capabilities w/o Level.';
list($paypal['level'], $paypal['ccaps'], $paypal['eotper']) = preg_split('/\\:/', $paypal['item_number'], 3);
$paypal['ip'] = preg_match('/ip address/i', $paypal['option_name2']) && $paypal['option_selection2'] ? $paypal['option_selection2'] : '';
$paypal['ip'] = !$paypal['ip'] && preg_match('/^[a-z0-9]+~[0-9\\.]+$/i', $paypal['invoice']) ? preg_replace('/^[a-z0-9]+~/i', '', $paypal['invoice']) : $paypal['ip'];
$paypal['currency'] = strtoupper($paypal['mc_currency']);
// Normalize input currency.
$paypal['currency_symbol'] = c_ws_plugin__s2member_utils_cur::symbol($paypal['currency']);
if (!empty($coupon['coupon_code']) && c_ws_plugin__s2member_utils_conds::pro_is_installed()) {
$coupon_class = new c_ws_plugin__s2member_pro_coupons();
$coupon_class->update_uses($coupon['coupon_code']);
}
if (preg_match('/(referenc|associat|updat|upgrad)/i', $paypal['option_name1']) && $paypal['option_selection1']) {
if (($user_id = c_ws_plugin__s2member_utils_users::get_user_id_with($paypal['txn_id'], $paypal['option_selection1'])) && is_object($user = new WP_User($user_id)) && $user->ID) {
if (!$user->has_cap('administrator')) {
$processing = $during = TRUE;
// Yes, we ARE processing this.
foreach (array_keys(get_defined_vars()) as $__v) {
$__refs[$__v] =& ${$__v};
}
do_action('ws_plugin__s2member_during_paypal_notify_during_before_new_ccaps', get_defined_vars());
unset($__refs, $__v);
$fields = get_user_option('s2member_custom_fields', $user_id);
// These will be needed in the routines below.
$user_reg_ip = get_user_option('s2member_registration_ip', $user_id);
// Original IP during Registration.
$user_reg_ip = $paypal['ip'] = $user_reg_ip ? $user_reg_ip : $paypal['ip'];
// Now merge conditionally.
if (is_multisite() && !is_user_member_of_blog($user_id)) {
add_existing_user_to_blog(array('user_id' => $user_id, 'role' => get_option('default_role')));
$user = new WP_User($user_id);
}
if ($paypal['ccaps'] && preg_match('/^-all/', str_replace('+', '', $paypal['ccaps']))) {
foreach ($user->allcaps as $cap => $cap_enabled) {
if (preg_match('/^access_s2member_ccap_/', $cap)) {
$user->remove_cap($ccap = $cap);
}
}
}
if ($paypal['ccaps'] && preg_replace('/^-all[' . "\r\n\t" . '\\s;,]*/', '', str_replace('+', '', $paypal['ccaps']))) {
foreach (preg_split('/[' . "\r\n\t" . '\\s;,]+/', preg_replace('/^-all[' . "\r\n\t" . '\\s;,]*/', '', str_replace('+', '', $paypal['ccaps']))) as $ccap) {
if (strlen($ccap = trim(strtolower(preg_replace('/[^a-z_0-9]/i', '', $ccap))))) {
$user->add_cap('access_s2member_ccap_' . $ccap);
}
}
}
if (!get_user_option('s2member_registration_ip', $user_id)) {
update_user_option($user_id, 's2member_registration_ip', $paypal['ip']);
}
if (!empty($coupon['full_coupon_code']) && c_ws_plugin__s2member_utils_conds::pro_is_installed()) {
$user_coupons = is_array($user_coupons = get_user_option('s2member_coupon_codes', $user_id)) ? $user_coupons : array();
$user_coupons = array_unique(array_merge($user_coupons, (array) $coupon['full_coupon_code']));
update_user_option($user_id, 's2member_coupon_codes', $user_coupons);
}
$paypal['s2member_log'][] = 's2Member Custom Capabilities updated w/ advanced update routines.';
$sbj = $GLOBALS['WS_PLUGIN__']['s2member']['o']['ccap_email_subject'];
// The same for standard and w/ Pro-Forms.
$msg = $GLOBALS['WS_PLUGIN__']['s2member']['o']['ccap_email_message'];
// The same for standard and w/ Pro-Forms.
$rec = $GLOBALS['WS_PLUGIN__']['s2member']['o']['ccap_email_recipients'];
// The same for standard and w/ Pro-Forms.
if (($rec = c_ws_plugin__s2member_utils_strings::fill_cvs($rec, $paypal['custom'])) && ($rec = preg_replace('/%%(?:subscr|txn)_id%%/i', c_ws_plugin__s2member_utils_strings::esc_refs($paypal['txn_id']), $rec))) {
if (($rec = preg_replace('/%%(?:subscr|txn)_baid%%/i', c_ws_plugin__s2member_utils_strings::esc_refs($paypal['txn_baid']), $rec)) && ($rec = preg_replace('/%%(?:subscr|txn)_cid%%/i', c_ws_plugin__s2member_utils_strings::esc_refs($paypal['txn_cid']), $rec))) {
if (($rec = preg_replace('/%%currency%%/i', c_ws_plugin__s2member_utils_strings::esc_refs($paypal['currency']), $rec)) && ($rec = preg_replace('/%%currency_symbol%%/i', c_ws_plugin__s2member_utils_strings::esc_refs($paypal['currency_symbol']), $rec))) {
if (($rec = preg_replace('/%%amount%%/i', c_ws_plugin__s2member_utils_strings::esc_refs($paypal['mc_gross']), $rec)) && ($rec = preg_replace('/%%txn_id%%/i', c_ws_plugin__s2member_utils_strings::esc_refs($paypal['txn_id']), $rec))) {
if (($rec = preg_replace('/%%item_number%%/i', c_ws_plugin__s2member_utils_strings::esc_refs($paypal['item_number']), $rec)) && ($rec = preg_replace('/%%item_name%%/i', c_ws_plugin__s2member_utils_strings::esc_refs($paypal['item_name']), $rec))) {
if (($rec = preg_replace('/%%first_name%%/i', c_ws_plugin__s2member_utils_strings::esc_dq(c_ws_plugin__s2member_utils_strings::esc_refs($paypal['first_name'])), $rec)) && ($rec = preg_replace('/%%last_name%%/i', c_ws_plugin__s2member_utils_strings::esc_dq(c_ws_plugin__s2member_utils_strings::esc_refs($paypal['last_name'])), $rec))) {
if ($rec = preg_replace('/%%full_name%%/i', c_ws_plugin__s2member_utils_strings::esc_dq(c_ws_plugin__s2member_utils_strings::esc_refs(trim($paypal['first_name'] . ' ' . $paypal['last_name']))), $rec)) {
// **NOTE** c_ws_plugin__s2member_utils_strings::esc_dq() is applied here. (ex. 'N\'ame' <email>).
if ($rec = preg_replace('/%%payer_email%%/i', c_ws_plugin__s2member_utils_strings::esc_refs($paypal['payer_email']), $rec)) {
if (($rec = preg_replace('/%%full_coupon_code%%/i', c_ws_plugin__s2member_utils_strings::esc_refs($coupon['full_coupon_code']), $rec)) && ($rec = preg_replace('/%%coupon_code%%/i', c_ws_plugin__s2member_utils_strings::esc_refs($coupon['coupon_code']), $rec)) && ($rec = preg_replace('/%%coupon_affiliate_id%%/i', c_ws_plugin__s2member_utils_strings::esc_refs($coupon['affiliate_id']), $rec))) {
if (($rec = preg_replace('/%%user_first_name%%/i', c_ws_plugin__s2member_utils_strings::esc_refs($user->first_name), $rec)) && ($rec = preg_replace('/%%user_last_name%%/i', c_ws_plugin__s2member_utils_strings::esc_refs($user->last_name), $rec))) {
if ($rec = preg_replace('/%%user_full_name%%/i', c_ws_plugin__s2member_utils_strings::esc_refs(trim($user->first_name . ' ' . $user->last_name)), $rec)) {
if ($rec = preg_replace('/%%user_email%%/i', c_ws_plugin__s2member_utils_strings::esc_refs($user->user_email), $rec)) {
if ($rec = preg_replace('/%%user_login%%/i', c_ws_plugin__s2member_utils_strings::esc_refs($user->user_login), $rec)) {
if ($rec = preg_replace('/%%user_ip%%/i', c_ws_plugin__s2member_utils_strings::esc_refs($user_reg_ip), $rec)) {
if ($rec = preg_replace('/%%user_id%%/i', c_ws_plugin__s2member_utils_strings::esc_refs($user_id), $rec)) {
if (($sbj = c_ws_plugin__s2member_utils_strings::fill_cvs($sbj, $paypal['custom'])) && ($sbj = preg_replace('/%%(?:subscr|txn)_id%%/i', c_ws_plugin__s2member_utils_strings::esc_refs($paypal['txn_id']), $sbj))) {
if (($sbj = preg_replace('/%%(?:subscr|txn)_baid%%/i', c_ws_plugin__s2member_utils_strings::esc_refs($paypal['txn_baid']), $sbj)) && ($sbj = preg_replace('/%%(?:subscr|txn)_cid%%/i', c_ws_plugin__s2member_utils_strings::esc_refs($paypal['txn_cid']), $sbj))) {
if (($sbj = preg_replace('/%%currency%%/i', c_ws_plugin__s2member_utils_strings::esc_refs($paypal['currency']), $sbj)) && ($sbj = preg_replace('/%%currency_symbol%%/i', c_ws_plugin__s2member_utils_strings::esc_refs($paypal['currency_symbol']), $sbj))) {
//.........这里部分代码省略.........
示例15: tdomf_create_dummy_user
function tdomf_create_dummy_user()
{
$rand_username = "tdomf_" . tdomf_random_string(5);
$rand_password = tdomf_random_string(8);
tdomf_log_message("Attempting to create dummy user {$rand_username}");
$user_id = wp_create_user($rand_username, $rand_password);
$user = new WP_User($user_id);
if ($user->has_cap("publish_posts")) {
$user->remove_cap("publish_posts");
}
$users = get_option(TDOMF_OPTION_CREATEDUSERS);
if ($users == false) {
$users = array($user_id);
add_option(TDOMF_OPTION_CREATEDUSERS, $users);
} else {
$users = array_merge($users, array($user_id));
update_option(TDOMF_OPTION_CREATEDUSERS, $users);
}
update_option(TDOMF_DEFAULT_AUTHOR, $user_id);
tdomf_log_message("Dummy user created for default author, user id = {$user_id}");
return $user_id;
}