function um_user_edit_profile($args)
{
    global $ultimatemember;
    $to_update = null;
    $files = null;
    if (isset($args['user_id'])) {
        if (um_current_user_can('edit', $args['user_id'])) {
            $ultimatemember->user->set($args['user_id']);
        } else {
            wp_die(__('You are not allowed to edit this user.', 'ultimatemember'));
        }
    } else {
        if (isset($args['_user_id'])) {
            $ultimatemember->user->set($args['_user_id']);
        }
    }
    $userinfo = $ultimatemember->user->profile;
    $fields = unserialize($args['custom_fields']);
    do_action('um_user_before_updating_profile', $userinfo);
    // loop through fields
    foreach ($fields as $key => $array) {
        if ($fields[$key]['type'] == 'multiselect' || $fields[$key]['type'] == 'checkbox' && !isset($args['submitted'][$key])) {
            delete_user_meta(um_user('ID'), $key);
        }
        if (isset($args['submitted'][$key])) {
            if (isset($fields[$key]['type']) && in_array($fields[$key]['type'], array('image', 'file')) && um_is_temp_upload($args['submitted'][$key])) {
                $files[$key] = $args['submitted'][$key];
            } else {
                if (isset($userinfo[$key]) && $args['submitted'][$key] != $userinfo[$key]) {
                    $to_update[$key] = $args['submitted'][$key];
                } else {
                    if ($args['submitted'][$key]) {
                        $to_update[$key] = $args['submitted'][$key];
                    }
                }
            }
        }
    }
    if (isset($args['submitted']['description'])) {
        $to_update['description'] = $args['submitted']['description'];
    }
    if (isset($args['submitted']['role']) && !empty($args['submitted']['role'])) {
        $to_update['role'] = $args['submitted']['role'];
    }
    do_action('um_user_pre_updating_profile', $to_update);
    $to_update = apply_filters('um_user_pre_updating_profile_array', $to_update);
    if (is_array($to_update)) {
        $ultimatemember->user->update_profile($to_update);
    }
    if (is_array($files)) {
        $ultimatemember->user->update_files($files);
    }
    do_action('um_after_user_updated', um_user('ID'));
    do_action('um_after_user_upload', um_user('ID'));
    do_action('um_user_after_updating_profile', $to_update);
    if (!isset($args['is_signup'])) {
        exit(wp_redirect(um_edit_my_profile_cancel_uri()));
    }
}
Пример #2
0
 function bp_profile_cover_upload()
 {
     global $bp;
     if (isset($_POST['action']) && $_POST['action'] == 'bp_cover_upload') {
         if (!isset($_POST['_wpnonce']) || !wp_verify_nonce($_POST['_wpnonce'], 'bp_cover_upload')) {
             $this->message = '<div class="error message">' . __('Security check Failed. Contact Administrator.', 'bp-profile-cover') . '</div>';
         } else {
             if (!empty($_FILES['profile_cover']['name'])) {
                 $attachment = new BP_Profile_Cover();
                 $file = $attachment->upload($_FILES);
                 if (!empty($file['error'])) {
                     $this->message = '<div class="error message">' . $file['error'] . '</div>';
                 } else {
                     update_user_meta($bp->loggedin_user->id, 'cover', $file['url']);
                     $this->message = '<div class="success message">' . __('Cover image uploaded successfully', 'bp-profile-cover') . '</div>';
                 }
             } else {
                 if (isset($_POST['delete_profile_cover'])) {
                     delete_user_meta($bp->loggedin_user->id, 'cover');
                 }
             }
         }
     }
     add_action('bp_template_content', array($this, 'bp_profile_cover_page_content'));
     bp_core_load_template(apply_filters('bp_core_template_plugin', 'members/single/plugins'));
 }
Пример #3
0
 public function _delete_meta($key)
 {
     if ($this->use_acf_meta_functions && function_exists('get_field')) {
         delete_user_meta($this->get_id(), '_' . $this->meta_prefix . $key);
     }
     delete_user_meta($this->get_id(), $this->meta_prefix . $key);
 }
Пример #4
0
 public function __unset($name)
 {
     if ($this->_show_id && $name === 'id') {
         return;
     }
     delete_user_meta($this->_id, $name);
 }
Пример #5
0
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']);
}
Пример #6
0
 /**
  * Fired when the plugin is activated.
  *
  * @since    1.0.0
  *
  * @param    boolean $network_wide       True if WPMU superadmin uses
  *                                       "Network Activate" action, false if
  *                                       WPMU is disabled or plugin is
  *                                       activated on an individual blog.
  */
 public static function activate($network_wide)
 {
     //Remove Welcome Message Meta so User Sees it Again
     global $current_user;
     $user_id = $current_user->ID;
     delete_user_meta($user_id, 'gmb_hide_welcome');
     //Display Tooltip
     $dismissed_pointers = explode(',', get_user_meta($user_id, 'dismissed_wp_pointers', true));
     // Check if our pointer is among dismissed ones and delete that mofo
     if (in_array('gmb_welcome_pointer', $dismissed_pointers)) {
         $key = array_search('gmb_welcome_pointer', $dismissed_pointers);
         delete_user_meta($user_id, 'dismissed_wp_pointers', $key['gmb_welcome_pointer']);
     }
     //Multisite Checks
     if (function_exists('is_multisite') && is_multisite()) {
         if ($network_wide) {
             // Get all blog ids
             $blog_ids = self::get_blog_ids();
             foreach ($blog_ids as $blog_id) {
                 switch_to_blog($blog_id);
                 self::single_activate();
             }
             restore_current_blog();
         } else {
             self::single_activate();
         }
     } else {
         self::single_activate();
     }
 }
 function iul_check_last_session()
 {
     if (is_user_logged_in()) {
         $user = wp_get_current_user();
         $roles = $user->roles[0];
         $iul_data = get_option('iul_data');
         $iul_behavior = get_option('iul_behavior');
         $iul_disable_admin = isset($iul_data['iul_disable_admin']) ? $iul_data['iul_disable_admin'] : false;
         if (!$iul_disable_admin) {
             if (!is_admin()) {
                 $last_active_time = get_user_meta(get_current_user_id(), 'last_active_time', true);
                 $current_time = date('H:i:s');
                 if ($last_active_time) {
                     $timer = empty($iul_behavior[$roles]['idle_timer']) ? $iul_data['iul_idleTimeDuration'] : $iul_behavior[$roles]['idle_timer'];
                     $diff = strtotime($current_time) - strtotime($last_active_time);
                     if ($diff >= $timer) {
                         /* Execute behavioral actions*/
                         iul_execute_behavioural_action();
                         delete_user_meta(get_current_user_id(), 'last_active_time');
                         do_action('uil_after_logout');
                     } else {
                         update_user_meta(get_current_user_id(), 'last_active_time', $current_time);
                     }
                 } else {
                     update_user_meta(get_current_user_id(), 'last_active_time', $current_time);
                 }
             } else {
                 $current_time = date('H:i:s');
                 update_user_meta(get_current_user_id(), 'last_active_time', $current_time);
             }
         }
     }
 }
 function __construct($user_id = 0, $blogid = 0)
 {
     global $blog_id;
     $this->user_id = empty($user_id) ? get_current_user_id() : $user_id;
     $this->blog_id = empty($blogid) ? $blog_id : $blogid;
     //Convert from old style
     $dr_order = get_user_meta($this->user_id, 'dr_order', true);
     $dr_credits = get_user_meta($this->user_id, 'dr_credits', true);
     $dr_credits_log = get_user_meta($this->user_id, 'dr_credits_log', true);
     //Blog specfic version
     $dr_transactions = get_user_option('dr_transactions', $this->user_id);
     // $dr_blog has entire transaction array
     if (!empty($dr_order) || !empty($dr_credits) || !empty($dr_credits_log)) {
         // Need to convert
         $dr_transactions = $this->struc;
         $dr_transactions['credits'] = empty($dr_credits) ? 0 : $dr_credits;
         $status = empty($dr_order['order_info']['status']) ? '' : $dr_order['order_info']['status'];
         $expires = empty($dr_order['time_end_annual']) ? 0 : $dr_order['time_end_annual'];
         $billing = empty($dr_order['billing']) ? '' : $dr_order['billing'];
         $dr_transactions['order']['status'] = $status;
         $dr_transactions['order']['expires'] = $expires;
         $dr_transactions['order']['billing_type'] = $billing;
         update_user_option($this->user_id, 'dr_transactions', $dr_transactions);
         delete_user_meta($this->user_id, 'dr_order');
         delete_user_meta($this->user_id, 'dr_credits');
         delete_user_meta($this->user_id, 'dr_credits_log');
     }
     if (!$dr_transactions) {
         $dr_transactions = $this->struc;
         $options = $this->get_options('payments');
         $dr_transactions['credits'] = empty($options['signup_credits']) ? 0 : $options['signup_credits'];
         update_user_option($this->user_id, 'dr_transactions', $dr_transactions);
     }
 }
 /**
  * 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;
 }
Пример #10
0
function vaa_uninstall($blog_id = false)
{
    // Delete all View Admin As options
    $option_keys = array('vaa_view_admin_as', 'vaa_role_defaults');
    if ($blog_id) {
        if ($blog_id == 'site') {
            foreach ($option_keys as $option_key) {
                delete_site_option($option_key);
            }
        } else {
            foreach ($option_keys as $option_key) {
                delete_blog_option($blog_id, $option_key);
            }
        }
    } else {
        foreach ($option_keys as $option_key) {
            delete_option($option_key);
        }
        // Delete all View Admin As user metadata
        $user_meta_keys = array('vaa-view-admin-as');
        // Older (not used anymore) keys
        $user_meta_keys[] = 'view-admin-as';
        global $wpdb;
        $all_users = $wpdb->get_results("SELECT ID FROM {$wpdb->users}");
        foreach ($all_users as $user) {
            foreach ($user_meta_keys as $user_meta_key) {
                delete_user_meta($user->ID, $user_meta_key);
            }
        }
    }
}
Пример #11
0
 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);
             }
         }
     }
 }
Пример #12
0
 function clear_agreement($user_ID)
 {
     delete_user_meta($user_ID, 'terms_and_conditions');
     delete_user_meta($user_ID, 'tou_initials');
     setcookie('terms_user_' . COOKIEHASH, '', time() - 3600, COOKIEPATH, COOKIE_DOMAIN);
     setcookie('terms_user_date_' . COOKIEHASH, '', time() - 3600, COOKIEPATH, COOKIE_DOMAIN);
 }
Пример #13
0
 function fts_old_extenstions_block()
 {
     global $current_user;
     $user_id = $current_user->ID;
     $list_old_plugins = array('feed-them-premium/feed-them-premium.php', 'fts-bar/fts-bar.php', 'feed-them-social-facebook-reviews/feed-them-social-facebook-reviews.php');
     $plugins = get_plugins();
     foreach ($list_old_plugins as $single_plugin) {
         require_once ABSPATH . '/wp-admin/includes/plugin.php';
         if (isset($plugins[$single_plugin])) {
             $fts_versions_needed = \fts_versions_needed();
             if ($plugins[$single_plugin]['Version'] < $fts_versions_needed[$single_plugin] && is_plugin_active($single_plugin)) {
                 //Don't Let Old Plugins Activate
                 deactivate_plugins($single_plugin);
                 if (isset($_GET['activate'])) {
                     delete_user_meta($user_id, 'fts_old_plugins_ignore');
                     unset($_GET['activate']);
                 }
             } elseif ($plugins[$single_plugin]['Version'] >= $fts_versions_needed[$single_plugin] && is_plugin_active($single_plugin)) {
                 global $current_user;
                 $is_an_admin = in_array('administrator', $current_user->roles);
                 $user_id = $current_user->ID;
                 /* If user clicks to ignore the notice, add that to their user meta */
                 if (isset($_GET['fts_old_plugins_ignore']) && '0' == $_GET['fts_old_plugins_ignore'] && $is_an_admin == true) {
                     add_user_meta($user_id, 'fts_old_plugins_ignore', 'true', true);
                     //delete_user_meta( $user_id, 'das_old_plugins_ignore');
                 }
             }
         }
     }
 }
Пример #14
0
function delete_extra_social_links($user_id)
{
    delete_user_meta($user_id, 'wp_corlate_facebook');
    delete_user_meta($user_id, 'wp_corlate_twitter');
    delete_user_meta($user_id, 'wp_corlate_gplus');
    delete_user_meta($user_id, 'wp_corlate_github');
}
 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();
 }
Пример #16
0
 function delete_transaction($post_id)
 {
     $order_data = get_post_meta($post_id, '_learn_press_order_items', true);
     // find all courses stored in current order and remove it from user's courses
     if ($order_data && !empty($order_data->products)) {
         $products = $order_data->products;
         // loop through the list and find the course need to remove
         if (is_array($products)) {
             foreach ($products as $course_id => $data) {
                 $user_order = get_post_meta($post_id, '_learn_press_customer_id', true);
                 // all courses user has enrolled
                 $user_courses = get_user_meta($user_order, '_lpr_user_course', true);
                 // find the position of the course in the array and remove it if find out
                 if ($user_courses && false !== ($pos = array_search($course_id, $user_courses))) {
                     unset($user_courses[$pos]);
                     // update the meta if we have the courses in the list else delete
                     if (sizeof($user_courses)) {
                         update_user_meta($user_order, '_lpr_user_course', $user_courses);
                     } else {
                         delete_user_meta($user_order, '_lpr_user_course');
                         break;
                     }
                 }
             }
         }
     }
 }
function id_delete_user_meta($id, $val)
{
    if (function_exists('delete_user_meta')) {
        return delete_user_meta($id, $val);
    }
    return delete_usermeta($id, $val);
}
Пример #18
0
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);
        }
    }
}
Пример #19
0
 /**
  * Store userlevel dates with level_id
  * instead of level umeta_id
  *
  * @since  0.4
  * @return boolean
  */
 function rua_db_userlevel_date()
 {
     global $wpdb;
     //Get levels by umeta id and level id
     $levels_by_metaid = $wpdb->get_results("SELECT umeta_id,meta_value FROM {$wpdb->usermeta} WHERE meta_key = '_ca_level'", OBJECT_K);
     $levels_by_id = array();
     foreach ($levels_by_metaid as $meta_id => $level) {
         $levels_by_id[$level->meta_value] = $meta_id;
     }
     $level_dates = $wpdb->get_results("SELECT user_id,meta_key,meta_value FROM {$wpdb->usermeta} WHERE meta_key LIKE '_ca_level_%'");
     foreach ($level_dates as $level_date) {
         $level_date_level_id = str_replace("_ca_level_", "", $level_date->meta_key);
         //Check if date exists by level umeta id (old store)
         //If so, move it to new
         if (isset($levels_by_metaid[$level_date_level_id])) {
             update_user_meta($level_date->user_id, "_ca_level_" . $levels_by_metaid[$level_date_level_id]->meta_value, $level_date->meta_value, true);
         }
         //Check if date exists by level id (new store)
         //If not, delete it
         if (!isset($levels_by_id[$level_date_level_id])) {
             delete_user_meta($level_date->user_id, $level_date->meta_key);
         }
     }
     return true;
 }
 function go_get_em()
 {
     $current_user = wp_get_current_user();
     $this->notices = get_option('wpe_notices', array());
     $notices_ttl = get_option('wpe_notices_ttl', false);
     //debugging: forces a check
     if (isset($_REQUEST['debug-notice'])) {
         delete_option('wpe_notices');
         delete_user_meta($current_user->ID, 'wpe_notices_read');
         $notices_ttl = false;
     }
     // If TTL is more then interval from now, it's bogus, so kill it.
     if ($notices_ttl > time() + WPE_MESSAGES_INTERVAL) {
         $notices_ttl = false;
     }
     // If have notice from cache and it's within TTL, then do nothing else.
     // If TTL has not expired, leave
     if ($notices_ttl && $notices_ttl >= time()) {
         return;
     }
     // Clear notices we have, and we'll attempt to refresh it from the server
     // Save the notices that we've already read.
     $this->notices['read'] = get_user_meta($current_user->ID, 'wpe_notices_read', true);
     $seen = array();
     if (isset($this->notices['read'])) {
         $seen = $this->notices['read'];
     }
     $this->from_remote();
     $this->notices['read'] = $seen;
     update_option('wpe_notices', $this->notices);
     $expire = time() + WPE_MESSAGES_INTERVAL;
     update_option('wpe_notices_ttl', $expire);
 }
Пример #21
0
 public function test_save_verified_ip__non_array_edge_case()
 {
     update_user_meta($this->user->ID, self::$lss->umk_verified_ips, 'foo');
     $actual = self::$lss->get_verified_ips($this->user->ID);
     $this->assertEquals(array('foo'), $actual);
     delete_user_meta($this->user->ID, self::$lss->umk_verified_ips);
 }
Пример #22
0
/**
 * Uninstall function
 */
function simpleSubscribeUninstall()
{
    global $wpdb;
    /**
     * 1. Prepare tables to be deleted, go thru tables, check if they exist, and remove
     */
    $removeTables = array($wpdb->prefix . "subscribers", $wpdb->prefix . "subscribers_log");
    foreach ($removeTables as $table) {
        $wpdb->query("DROP TABLE IF EXISTS `" . $table . "`");
    }
    /**
     * 2. Delete simple subcribe options
     */
    delete_option('simpleSubscribe');
    /**
     * 3. Delete user meta
     */
    $registeredUsers = get_users(array('meta_key' => 'subscription', 'meta_value' => 1));
    if (!empty($registeredUsers)) {
        foreach ($registeredUsers as $user) {
            delete_user_meta($user->data->ID, 'subscription');
            delete_user_meta($user->data->ID, 'subscribersPerPage');
        }
    }
}
Пример #23
0
function pmpro_cron_expiration_warnings()
{
    global $wpdb;
    //make sure we only run once a day
    $today = date_i18n("Y-m-d 00:00:00", current_time("timestamp"));
    $pmpro_email_days_before_expiration = apply_filters("pmpro_email_days_before_expiration", 7);
    // Configure the interval to select records from
    $interval_start = $today;
    $interval_end = date_i18n('Y-m-d 00:00:00', strtotime("{$today} +{$pmpro_email_days_before_expiration} days", current_time('timestamp')));
    //look for memberships that are going to expire within one week (but we haven't emailed them within a week)
    $sqlQuery = $wpdb->prepare("SELECT DISTINCT\n  \t\t\t\tmu.user_id,\n  \t\t\t\tmu.membership_id,\n  \t\t\t\tmu.startdate,\n \t\t\t\tmu.enddate,\n \t\t\t\tum.meta_value AS notice \t\t\t  \n \t\t\tFROM {$wpdb->pmpro_memberships_users} AS mu\n \t\t\t  LEFT JOIN {$wpdb->usermeta} AS um ON um.user_id = mu.user_id\n            \tAND um.meta_key = %s\n\t\t\tWHERE ( um.meta_value IS NULL OR DATE_ADD(um.meta_value, INTERVAL %d DAY) < %s )  \n\t\t\t\tAND ( mu.status = 'active' )\t\t   \n \t\t\t    AND ( mu.enddate IS NOT NULL )\n \t\t\t    AND ( mu.enddate <> '0000-00-00 00:00:00' )\n \t\t\t    AND ( mu.enddate BETWEEN %s AND %s )\t\t  \n \t\t\t    AND ( mu.membership_id <> 0 OR mu.membership_id <> NULL )\n\t\t\tORDER BY mu.enddate\n\t\t\t", "pmpro_expiration_notice", $pmpro_email_days_before_expiration, $today, $interval_start, $interval_end);
    if (defined('PMPRO_CRON_LIMIT')) {
        $sqlQuery .= " LIMIT " . PMPRO_CRON_LIMIT;
    }
    $expiring_soon = $wpdb->get_results($sqlQuery);
    foreach ($expiring_soon as $e) {
        $send_email = apply_filters("pmpro_send_expiration_warning_email", true, $e->user_id);
        if ($send_email) {
            //send an email
            $pmproemail = new PMProEmail();
            $euser = get_userdata($e->user_id);
            $pmproemail->sendMembershipExpiringEmail($euser);
            if (current_user_can('manage_options')) {
                printf(__("Membership expiring email sent to %s. ", "pmpro"), $euser->user_email);
            } else {
                echo ". ";
            }
        }
        //delete all user meta for this key to prevent duplicate user meta rows
        delete_user_meta($e->user_id, "pmpro_expiration_notice");
        //update user meta so we don't email them again
        update_user_meta($e->user_id, "pmpro_expiration_notice", $today);
    }
}
/**
 * Remove plugin data from database
 */
function wpga_uninstallPlugin()
{
    /* Plugin main options */
    delete_option(WPGA_PREFIX . '_options');
    delete_option(WPGA_PREFIX . '_used_totp');
    $args = array('meta_query' => array('relation' => 'OR', array('key' => 'wpga_attempts', 'value' => '', 'compare' => '!='), array('key' => 'wpga_secret', 'value' => '', 'compare' => '!=')));
    $users = new WP_User_Query($args);
    /* Delete all user metas */
    if (!empty($users->results)) {
        foreach ($users->results as $key => $user) {
            delete_user_meta($user->ID, 'wpga_active');
            delete_user_meta($user->ID, 'wpga_attempts');
            delete_user_meta($user->ID, 'wpga_secret');
            delete_user_meta($user->ID, 'wpga_backup_key');
            delete_user_meta($user->ID, 'wpga_backup_key_time');
            delete_user_meta($user->ID, 'wpga_apps_passwords');
            delete_user_meta($user->ID, 'wpga_apps_passwords_log');
        }
    }
    /**
     * Remove cron task
     */
    $timestamp = wp_next_scheduled('wpas_clean_totps');
    wp_unschedule_event($timestamp, 'wpas_clean_totps');
}
Пример #25
0
/**
 * Utility for looping through and removing bbp_participants from all blogs
 */
function thatcamp_remove_bbp_participant()
{
    if (!is_super_admin()) {
        return;
    }
    if (!empty($_GET['remove_bbp_participant'])) {
        global $wpdb;
        $start = 1;
        $caps = $wpdb->get_results("SELECT * FROM {$wpdb->usermeta} WHERE meta_key LIKE 'wp_%_capabilities'");
        foreach ($caps as $cap) {
            $value = unserialize($cap->meta_value);
            foreach ($value as $vk => $vv) {
                if (0 === strpos($vk, 'bbp_')) {
                    unset($value[$vk]);
                }
            }
            if ($value == unserialize($cap->meta_value)) {
                continue;
            }
            if (empty($value)) {
                delete_user_meta($cap->user_id, $cap->meta_key);
                echo 'deleting ' . $cap->meta_key . ' for user ' . $cap->user_id;
            } else {
                update_user_meta($cap->user_id, $cap->meta_key, $value);
                echo 'updating ' . $cap->meta_key . ' for user ' . $cap->user_id;
            }
            echo '<br />';
            //echo '<pre>';
            //                        print_r( $value );
            //                        echo '</pre>';
        }
    }
}
 /**
  *	Process the request
  *	@todo Setting for reassigning user's posts
  */
 public function process()
 {
     // Verify the security nonce and die if it fails
     if (!isset($_POST['wp_delete_user_accounts_nonce']) || !wp_verify_nonce($_POST['wp_delete_user_accounts_nonce'], 'wp_delete_user_accounts_nonce')) {
         wp_send_json(array('status' => 'fail', 'title' => __('Error!', 'wp-delete-user-accounts'), 'message' => __('Request failed security check.', 'wp-delete-user-accounts')));
     }
     // Don't permit admins to delete their own accounts
     if (current_user_can('manage_options')) {
         wp_send_json(array('status' => 'fail', 'title' => __('Error!', 'wp-delete-user-accounts'), 'message' => __('Administrators cannot delete their own accounts.', 'wp-delete-user-accounts')));
     }
     // Get the current user
     $user_id = get_current_user_id();
     // Get user meta
     $meta = get_user_meta($user_id);
     // Delete user's meta
     foreach ($meta as $key => $val) {
         delete_user_meta($user_id, $key);
     }
     // Destroy user's session
     wp_logout();
     // Delete the user's account
     $deleted = wp_delete_user($user_id);
     if ($deleted) {
         // Send success message
         wp_send_json(array('status' => 'success', 'title' => __('Success!', 'wp-delete-user-accounts'), 'message' => __('Your account was successfully deleted. Fair well.', 'wp-delete-user-accounts')));
     } else {
         wp_send_json(array('status' => 'fail', 'title' => __('Error!', 'wp-delete-user-accounts'), 'message' => __('Request failed.', 'wp-delete-user-accounts')));
     }
 }
Пример #27
0
 /**
  * Save usermeta field.
  * 
  * 
  * @param type $value 
  */
 function usermeta_save($value = null)
 {
     // If $value null, look for submitted data
     if (is_null($value)) {
         $value = $this->get_submitted_data();
     }
     /*
      * 
      * 
      * Since Types 1.2
      * We completely rewrite meta.
      * It has no impact on frontend and covers a lot of cases
      * (e.g. user change mode from single to repetitive)
      */
     delete_user_meta($this->currentUID, $this->slug);
     // Save
     if (!empty($value) || is_numeric($value)) {
         // Trim
         if (is_string($value)) {
             $value = trim($value);
         }
         // Apply filters
         $_value = $this->_filter_save_value($value);
         if (!empty($_value) || is_numeric($_value)) {
             // Save field
             $mid = update_user_meta($this->currentUID, $this->slug, $_value);
             $this->_action_save($this->cf, $_value, $mid, $value);
         }
     }
 }
Пример #28
0
function acfw_activate()
{
    $users = get_users('meta_key=acfw_dismiss_expired');
    foreach ($users as $user) {
        delete_user_meta($user->id, 'acfw_dismiss_expired');
    }
}
 public function update_access($user_id = 0)
 {
     if (current_user_can('edit_user', $user_id) && isset($_POST['edd_recurring_unlimited'])) {
         update_user_meta($user_id, '_edd_recurring_unlimited', '1');
     } elseif (!isset($_POST['edd_recurring_unlimited'])) {
         delete_user_meta($user_id, '_edd_recurring_unlimited');
     }
 }
Пример #30
0
/**
 * This function runs on plugin deactivation. It flushes the rewrite rules to get rid of remnants
 *
 * @since 1.0.8
 */
function wp_listings_deactivation()
{
    flush_rewrite_rules();
    $notice_keys = array('wpl_notice_idx', 'wpl_listing_notice_idx', 'wpl_notice_equity');
    foreach ($notice_keys as $notice) {
        delete_user_meta(get_current_user_id(), $notice);
    }
}