当前位置: 首页>>代码示例>>PHP>>正文


PHP WP_User::get_data_by方法代码示例

本文整理汇总了PHP中WP_User::get_data_by方法的典型用法代码示例。如果您正苦于以下问题:PHP WP_User::get_data_by方法的具体用法?PHP WP_User::get_data_by怎么用?PHP WP_User::get_data_by使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在WP_User的用法示例。


在下文中一共展示了WP_User::get_data_by方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。

示例1: get_user_by

 function get_user_by($field, $value)
 {
     $userdata = WP_User::get_data_by($field, $value);
     if (!$userdata) {
         return false;
     }
     $user = new WP_User();
     $user->init($userdata);
     return $user;
 }
开发者ID:sevir,项目名称:toffy-lite,代码行数:10,代码来源:wp_igniter.php

示例2: _getWPUser

 private function _getWPUser($id)
 {
     $userdata = WP_User::get_data_by('login', $id);
     if (!$userdata) {
         return false;
     }
     $user = new WP_User();
     $user->init($userdata);
     return $user;
 }
开发者ID:jelicanin,项目名称:Docs-to-WordPress,代码行数:10,代码来源:docs-to-wp.php

示例3: __construct


//.........这里部分代码省略.........
         $this->auto_confirm = (bool) $args['auto_confirm'];
     }
     $this->process_events = (bool) $args['process_events'];
     $this->process_confirmation = (bool) $args['process_confirmation'];
     $this->process_list_server = (bool) $args['process_list_server'];
     $this->user_initiated = (bool) $args['user_initiated'];
     $this->user_initiated = $this->plugin->utils_sub->checkUserInitiatedByAdmin($this->data['email'] ? $this->data['email'] : ($this->is_update && $this->sub ? $this->sub->email : ''), $this->user_initiated);
     $this->ui_protected_data_keys_enable = $this->user_initiated && $args['ui_protected_data_keys_enable'];
     $this->ui_protected_data_user = null;
     // Recording here; but can't be filled until later below.
     if ($this->user_initiated) {
         // Protected data keys?
         if ($this->ui_protected_data_keys_enable) {
             $this->data['user_id'] = null;
             $this->data['insertion_ip'] = null;
             $this->data['insertion_region'] = null;
             $this->data['insertion_country'] = null;
             $this->data['last_ip'] = null;
             $this->data['last_region'] = null;
             $this->data['last_country'] = null;
             $this->data['insertion_time'] = null;
             $this->data['last_update_time'] = null;
         }
     }
     if (isset($args['user_allow_0'])) {
         // Iff `$this->user_initiated` also.
         $this->user_allow_0 = $this->user_initiated && $args['user_allow_0'];
     } else {
         $this->user_allow_0 = $this->user_initiated;
         // Defaults to this value.
     }
     $this->keep_existing = (bool) $args['keep_existing'];
     $this->check_blacklist = (bool) $args['check_blacklist'];
     /* Related to user. */
     if (!isset($this->user) || !$this->user->ID) {
         if ((int) $this->data['user_id'] > 0) {
             // A potentially new user ID?
             $this->user = new \WP_User((int) $this->data['user_id']);
         }
     }
     if ($this->user_initiated && $this->ui_protected_data_keys_enable && !isset($this->data['user_id']) && $args['ui_protected_data_user'] instanceof \WP_User) {
         $this->user = $this->ui_protected_data_user = $args['ui_protected_data_user'];
     }
     if (!isset($this->user) || !$this->user->ID) {
         if ($this->user_initiated) {
             $this->user = wp_get_current_user();
         }
     }
     if (!isset($this->user) || !$this->user->ID) {
         if ($this->is_update && $this->sub && $this->sub->user_id) {
             $this->user = new \WP_User($this->sub->user_id);
         }
     }
     if (!isset($this->user) || !$this->user->ID) {
         if ((string) $this->data['email']) {
             // A potentially new email address?
             if ($_user = \WP_User::get_data_by('email', (string) $this->data['email'])) {
                 $this->user = new \WP_User($_user->ID);
             }
         }
     }
     unset($_user);
     // Housekeeping.
     if (!isset($this->user) || !$this->user->ID) {
         if ($this->is_update && $this->sub && $this->sub->email) {
             if ($_user = \WP_User::get_data_by('email', $this->sub->email)) {
                 $this->user = new \WP_User($_user->ID);
             }
         }
     }
     unset($_user);
     // Housekeeping.
     if (!isset($this->user) || !$this->user->ID) {
         if ($this->user_allow_0 && $this->data['user_id'] === 0) {
             $this->user = new \WP_User(0);
         }
     }
     if (!$this->user_allow_0 && $this->user && !$this->user->ID) {
         $this->user = null;
         // Do not allow `0` in this case.
     }
     /* Related to current user. */
     if ($this->user_initiated) {
         $this->is_current_user = true;
     } else {
         $this->is_current_user = $this->user && $this->plugin->utils_user->isCurrent($this->user, $this->user_allow_0);
     }
     /* Related to duplicates. */
     $this->duplicate_key_ids = [];
     // Initialize.
     $this->other_duplicate_ids = [];
     // Initialize.
     /* Related to success/error reporting. */
     $this->errors = [];
     // Initialize.
     $this->successes = [];
     // Initialize.
     /* OK, let's do this. */
     $this->maybeInsertUpdate();
 }
开发者ID:websharks,项目名称:comment-mail,代码行数:101,代码来源:SubInserter.php

示例4: userpro_profile_updated

function userpro_profile_updated($user_id, $old_user_data)
{
    global $userpro;
    if (!empty($user_id)) {
        $current_user_data = WP_User::get_data_by('id', $user_id);
        $display_name = $current_user_data->display_name;
        update_user_meta($user_id, 'display_name', $display_name);
    }
    $userpro->clear_cache();
}
开发者ID:Darciro,项目名称:PPM,代码行数:10,代码来源:hooks-actions.php

示例5: wp_insert_user

/**
 * Insert a user into the database.
 *
 * Most of the `$userdata` array fields have filters associated with the values. Exceptions are
 * 'ID', 'rich_editing', 'comment_shortcuts', 'admin_color', 'use_ssl',
 * 'user_registered', and 'role'. The filters have the prefix 'pre_user_' followed by the field
 * name. An example using 'description' would have the filter called, 'pre_user_description' that
 * can be hooked into.
 *
 * @since 2.0.0
 * @since 3.6.0 The `aim`, `jabber`, and `yim` fields were removed as default user contact
 *              methods for new installs. See wp_get_user_contact_methods().
 *
 * @global wpdb $wpdb WordPress database object for queries.
 *
 * @param array|object|WP_User $userdata {
 *     An array, object, or WP_User object of user data arguments.
 *
 *     @type int         $ID                   User ID. If supplied, the user will be updated.
 *     @type string      $user_pass            The plain-text user password.
 *     @type string      $user_login           The user's login username.
 *     @type string      $user_nicename        The URL-friendly user name.
 *     @type string      $user_url             The user URL.
 *     @type string      $user_email           The user email address.
 *     @type string      $display_name         The user's display name.
 *                                             Default is the the user's username.
 *     @type string      $nickname             The user's nickname.
 *                                             Default is the the user's username.
 *     @type string      $first_name           The user's first name. For new users, will be used
 *                                             to build the first part of the user's display name
 *                                             if `$display_name` is not specified.
 *     @type string      $last_name            The user's last name. For new users, will be used
 *                                             to build the second part of the user's display name
 *                                             if `$display_name` is not specified.
 *     @type string      $description          The user's biographical description.
 *     @type string|bool $rich_editing         Whether to enable the rich-editor for the user.
 *                                             False if not empty.
 *     @type string|bool $comment_shortcuts    Whether to enable comment moderation keyboard
 *                                             shortcuts for the user. Default false.
 *     @type string      $admin_color          Admin color scheme for the user. Default 'fresh'.
 *     @type bool        $use_ssl              Whether the user should always access the admin over
 *                                             https. Default false.
 *     @type string      $user_registered      Date the user registered. Format is 'Y-m-d H:i:s'.
 *     @type string|bool $show_admin_bar_front Whether to display the Admin Bar for the user on the
 *                                             site's frontend. Default true.
 *     @type string      $role                 User's role.
 * }
 * @return int|WP_Error The newly created user's ID or a WP_Error object if the user could not
 *                      be created.
 */
function wp_insert_user($userdata)
{
    global $wpdb;
    if ($userdata instanceof stdClass) {
        $userdata = get_object_vars($userdata);
    } elseif ($userdata instanceof WP_User) {
        $userdata = $userdata->to_array();
    }
    // Are we updating or creating?
    if (!empty($userdata['ID'])) {
        $ID = (int) $userdata['ID'];
        $update = true;
        $old_user_data = WP_User::get_data_by('id', $ID);
        // hashed in wp_update_user(), plaintext if called directly
        $user_pass = $userdata['user_pass'];
    } else {
        $update = false;
        // Hash the password
        $user_pass = wp_hash_password($userdata['user_pass']);
    }
    $sanitized_user_login = sanitize_user($userdata['user_login'], true);
    /**
     * Filter a username after it has been sanitized.
     *
     * This filter is called before the user is created or updated.
     *
     * @since 2.0.3
     *
     * @param string $sanitized_user_login Username after it has been sanitized.
     */
    $pre_user_login = apply_filters('pre_user_login', $sanitized_user_login);
    //Remove any non-printable chars from the login string to see if we have ended up with an empty username
    $user_login = trim($pre_user_login);
    if (empty($user_login)) {
        return new WP_Error('empty_user_login', __('Cannot create a user with an empty login name.'));
    }
    if (!$update && username_exists($user_login)) {
        return new WP_Error('existing_user_login', __('Sorry, that username already exists!'));
    }
    // If a nicename is provided, remove unsafe user characters before
    // using it. Otherwise build a nicename from the user_login.
    if (!empty($userdata['user_nicename'])) {
        $user_nicename = sanitize_user($userdata['user_nicename'], true);
    } else {
        $user_nicename = $user_login;
    }
    $user_nicename = sanitize_title($user_nicename);
    // Store values to save in user meta.
    $meta = array();
    /**
//.........这里部分代码省略.........
开发者ID:rizkafitri,项目名称:WordPress-1,代码行数:101,代码来源:user.php

示例6: get_user_by

 function get_user_by($field, $value)
 {
     $obj = c2c_AllowMultipleAccounts::$instance;
     if ('email' == $field && $obj->during_user_creation && !$obj->has_exceeded_limit($value)) {
         return false;
     }
     $userdata = WP_User::get_data_by($field, $value);
     if (!$userdata) {
         return false;
     }
     $user = new WP_User();
     $user->init($userdata);
     return $user;
 }
开发者ID:adisonc,项目名称:MaineLearning,代码行数:14,代码来源:allow-multiple-accounts.php

示例7: test_wp_insert_user_should_not_wipe_existing_password

 /**
  * @ticket 29880
  */
 public function test_wp_insert_user_should_not_wipe_existing_password()
 {
     $user_details = array('user_login' => rand_str(), 'user_pass' => 'password', 'user_email' => rand_str() . '@example.com');
     $user_id = wp_insert_user($user_details);
     $this->assertEquals($user_id, email_exists($user_details['user_email']));
     // Check that providing an empty password doesn't remove a user's password.
     $user_details['ID'] = $user_id;
     $user_details['user_pass'] = '';
     $user_id = wp_insert_user($user_details);
     $user = WP_User::get_data_by('id', $user_id);
     $this->assertNotEmpty($user->user_pass);
 }
开发者ID:agup006,项目名称:WordPress,代码行数:15,代码来源:user.php

示例8: loadUser

function loadUser($login, $mail)
{
    $userobj = new WP_User();
    $user = $userobj->get_data_by('login', $login);
    openam_debug("loadUser: user object: " . print_r($user, TRUE));
    $user = new WP_User($user->ID);
    // Attempt to load up the user with that ID
    if ($user->ID == 0) {
        // User did not exist
        $userdata = array('user_email' => $mail, 'user_login' => $login);
        $new_user_id = wp_insert_user($userdata);
        // A new user has been created
        // Load the new user info
        $user = new WP_User($new_user_id);
    }
    openam_debug("loadUser: WP_User loaded: " . print_r($user, TRUE));
    return $user;
}
开发者ID:T-A-R-L-A,项目名称:www.tarla.org.tr,代码行数:18,代码来源:openam-rest.php

示例9: wp_update_user

/**
 * Update an user in the database.
 *
 * It is possible to update a user's password by specifying the 'user_pass'
 * value in the $userdata parameter array.
 *
 * If $userdata does not contain an 'ID' key, then a new user will be created
 * and the new user's ID will be returned.
 *
 * If current user's password is being updated, then the cookies will be
 * cleared.
 *
 * @since 2.0.0
 * @see wp_insert_user() For what fields can be set in $userdata
 * @uses wp_insert_user() Used to update existing user or add new one if user doesn't exist already
 *
 * @param array $userdata An array of user data.
 * @return int The updated user's ID.
 */
function wp_update_user($userdata)
{
    $ID = (int) $userdata['ID'];
    // First, get all of the original fields
    $user = WP_User::get_data_by('id', $ID);
    // Escape data pulled from DB.
    $user = add_magic_quotes(get_object_vars($user));
    // If password is changing, hash it now.
    if (!empty($userdata['user_pass'])) {
        $plaintext_pass = $userdata['user_pass'];
        $userdata['user_pass'] = wp_hash_password($userdata['user_pass']);
    }
    wp_cache_delete($user['user_email'], 'useremail');
    // Merge old and new fields with new fields overwriting old ones.
    $userdata = array_merge($user, $userdata);
    $user_id = wp_insert_user($userdata);
    // Update the cookies if the password changed.
    $current_user = wp_get_current_user();
    if ($current_user->ID == $ID) {
        if (isset($plaintext_pass)) {
            wp_clear_auth_cookie();
            wp_set_auth_cookie($ID);
        }
    }
    return $user_id;
}
开发者ID:netconstructor,项目名称:WordPress,代码行数:45,代码来源:user.php

示例10: getUserBy

 public static function getUserBy($field, $value, $focus = false)
 {
     if (class_exists(InnThemeUser::class) && method_exists(InnThemeUser::class, 'getUserBy')) {
         InnThemeUser::getUserBy($field, $value, $focus);
     }
     static $cache = [];
     $cacheID = $field . $value . $focus;
     if (!$focus && isset($cache[$cacheID])) {
         return $cache[$cacheID];
     }
     $userdata = \WP_User::get_data_by($field, $value);
     if (!$userdata) {
         $cache[$cacheID] = false;
         return false;
     }
     $user = new \WP_User();
     $user->init($userdata);
     $cache[$cacheID] = $user;
     return $user;
 }
开发者ID:kmvan,项目名称:poil10n,代码行数:20,代码来源:Api.php

示例11: postie_warnings

/**
 * set up actions to show relevant warnings, 
 * if mail server is not set, or if IMAP extension is not available
 */
function postie_warnings()
{
    $config = config_Read();
    if ((empty($config['mail_server']) || empty($config['mail_server_port']) || empty($config['mail_userid']) || empty($config['mail_password'])) && !isset($_POST['submit'])) {
        function postie_enter_info()
        {
            echo "<div id='postie-info-warning' class='updated fade'><p><strong>" . __('Postie is almost ready.', 'postie') . "</strong> " . sprintf(__('You must <a href="%1$s">enter your email settings</a> for it to work.', 'postie'), "options-general.php?page=postie/postie.php") . "</p></div> ";
        }
        add_action('admin_notices', 'postie_enter_info');
    }
    $p = strtolower($config['input_protocol']);
    if (!function_exists('imap_mime_header_decode') && ($p == 'imap' || $p == 'imap-ssl' || $p == 'pop-ssl')) {
        function postie_imap_warning()
        {
            echo "<div id='postie-imap-warning' class='error'><p><strong>";
            echo __('Warning: the IMAP php extension is not installed. Postie can not use IMAP, IMAP-SSL or POP-SSL without this extension.', 'postie');
            echo "</strong></p></div>";
        }
        add_action('admin_notices', 'postie_imap_warning');
    }
    if ($p == 'pop3' && $config['email_tls']) {
        function postie_tls_warning()
        {
            echo "<div id='postie-lst-warning' class='error'><p><strong>";
            echo __('Warning: The POP3 connector does not support TLS.', 'postie');
            echo "</strong></p></div>";
        }
        add_action('admin_notices', 'postie_tls_warning');
    }
    if (!function_exists('mb_detect_encoding')) {
        function postie_mbstring_warning()
        {
            echo "<div id='postie-mbstring-warning' class='error'><p><strong>";
            echo __('Warning: the Multibyte String php extension (mbstring) is not installed. Postie will not function without this extension.', 'postie');
            echo "</strong></p></div>";
        }
        add_action('admin_notices', 'postie_mbstring_warning');
    }
    $userdata = WP_User::get_data_by('login', $config['admin_username']);
    if (!$userdata) {
        function postie_adminuser_warning()
        {
            echo "<div id='postie-mbstring-warning' class='error'><p><strong>";
            echo __('Warning: the Admin username is not a valid WordPress login. Postie may reject emails if this is not corrected.', 'postie');
            echo "</strong></p></div>";
        }
        add_action('admin_notices', 'postie_adminuser_warning');
    }
}
开发者ID:donwea,项目名称:nhap.org,代码行数:53,代码来源:postie.php

示例12: genSchemaByPostId

 static function genSchemaByPostId($post_id, &$post = null)
 {
     require_once dirname(__FILE__) . DIRECTORY_SEPARATOR . 'schema.php';
     $post = get_post($post_id);
     $schema = new BaidusubmitSchemaPost();
     $schema->setTitle($post->post_title);
     $schema->setLastmod($post->post_modified);
     $schema->setCommentCount($post->comment_count);
     $schema->setPublishTime($post->post_date);
     $_user = WP_User::get_data_by('id', $post->post_author);
     $schema->setAuthor($_user->display_name);
     $_url = BaidusubmitSitemap::genPostUrl($post);
     $schema->setUrl($_url);
     $schema->setLoc($_url);
     $_term = get_the_terms($post, 'category');
     if ($_term && isset($_term[0])) {
         $schema->setTerm($_term[0]->name);
     }
     $_tags = get_the_terms($post, 'post_tag');
     if ($_tags && is_array($_tags)) {
         $_t = array();
         foreach ($_tags as $x) {
             $_t[] = $x->name;
         }
         $schema->setTags($_t);
     }
     $multimedia = array();
     $_content = BaidusubmitSitemap::filterContent($post, $multimedia);
     $schema->setContent($_content);
     if (!empty($multimedia['image'])) {
         $schema->setPictures($multimedia['image']);
     }
     if (!empty($multimedia['audio'])) {
         foreach ($multimedia['audio'] as $a) {
             $audio = new BaidusubmitSchemaAudio();
             $audio->setName((string) @$a['name']);
             $audio->setUrl((string) @$a['url']);
             $schema->addAudio($audio);
         }
         unset($a, $audio);
     }
     if (!empty($multimedia['video'])) {
         foreach ($multimedia['video'] as $v) {
             $video = new BaidusubmitSchemaVideo();
             $video->setCaption((string) @$v['caption']);
             $video->setThumbnail((string) @$v['thumbnail']);
             $video->setUrl((string) @$v['url']);
             $schema->addVideo($video);
         }
         unset($v, $video);
     }
     $commentlist = BaidusubmitSitemap::getCommentListByPostId($post->ID);
     if ($commentlist) {
         foreach ($commentlist as $c) {
             $comm = new BaidusubmitSchemaComment();
             $comm->setText($c->comment_content);
             $comm->setTime($c->comment_date);
             $comm->setCreator($c->comment_author);
             $schema->addComment($comm);
         }
         $schema->setLatestCommentTime($c->comment_date);
         unset($c, $comm);
     } else {
         $schema->setLatestCommentTime($post->post_date);
     }
     return $schema;
 }
开发者ID:yszar,项目名称:linuxwp,代码行数:67,代码来源:sitemap.php

示例13: get_user_by

 function get_user_by($field, $value)
 {
     global $xt_during_user_creation;
     if ('email' == $field && $xt_during_user_creation) {
         return false;
     }
     $userdata = WP_User::get_data_by($field, $value);
     if (!$userdata) {
         return false;
     }
     $user = new WP_User();
     $user->init($userdata);
     return $user;
 }
开发者ID:aspirin,项目名称:wp-xintaoke,代码行数:14,代码来源:wp-xintaoke.php

示例14: save

 public static function save($customer_id, $new = false)
 {
     global $the_customer, $wpdb;
     $the_customer = new WC_CRM_Customer($customer_id);
     wc_crm_clear_notices();
     $data = array('status' => $_POST['customer_status']);
     $old_user_data = array();
     if ($the_customer->user_id > 0) {
         if (empty($_POST['user_email'])) {
             wc_crm_add_notice(__('Please enter an e-mail address.', 'wc_crm'), 'error');
         } elseif (!is_email($_POST['user_email'])) {
             wc_crm_add_notice(__("The email address isn't correct.", 'wc_crm'), 'error');
         } elseif (($owner_id = email_exists($_POST['user_email'])) && $owner_id != $the_customer->user_id) {
             wc_crm_add_notice(__("This email is already registered, please choose another one.", 'wc_crm'), 'error');
         }
         if (wc_crm_notice_count('error') > 0) {
             return;
         }
         $old_user_data = WP_User::get_data_by('id', $the_customer->user_id);
         $user_data_up = array('ID' => $the_customer->user_id, 'user_url' => $_POST['customer_site'], 'user_email' => $_POST['user_email']);
         wp_update_user($user_data_up);
         $the_customer->init_general_fields();
         $the_customer->init_address_fields();
         if ($the_customer->general_fields) {
             foreach ($the_customer->general_fields as $key => $field) {
                 if (!isset($field['type'])) {
                     $field['type'] = 'text';
                 }
                 if (!isset($field['meta_key'])) {
                     $field['meta_key'] = $key;
                 }
                 if (!isset($_POST[$key])) {
                     if ($field['type'] == 'multiselect') {
                         update_user_meta($the_customer->user_id, $field['meta_key'], array());
                     }
                     continue;
                 }
                 switch ($key) {
                     case "customer_twitter":
                         $post_value = str_replace('@', '', $_POST['customer_twitter']);
                         break;
                     default:
                         $post_value = $_POST[$key];
                         break;
                 }
                 update_user_meta($the_customer->user_id, $field['meta_key'], $post_value);
             }
         }
         if ($the_customer->billing_fields) {
             foreach ($the_customer->billing_fields as $key => $field) {
                 if (!isset($_POST['_billing_' . $key])) {
                     continue;
                 }
                 $post_value = $_POST['_billing_' . $key];
                 update_user_meta($the_customer->user_id, 'billing_' . $key, $post_value);
             }
         }
         if ($the_customer->shipping_fields) {
             foreach ($the_customer->shipping_fields as $key => $field) {
                 if (!isset($_POST['_shipping_' . $key])) {
                     continue;
                 }
                 $post_value = $_POST['_shipping_' . $key];
                 update_user_meta($the_customer->user_id, 'shipping_' . $key, $post_value);
             }
         }
         update_user_meta($the_customer->user_id, 'preferred_payment_method', $_POST['_payment_method']);
         update_user_meta($the_customer->user_id, 'payment_method', $_POST['_payment_method']);
         $group_ids = array();
         if (isset($_POST['wc_crm_customer_groups'])) {
             $group_ids = $_POST['wc_crm_customer_groups'];
         }
         $the_customer->update_groups($group_ids);
         if (isset($_POST['account_name'])) {
             $account_id = $_POST['account_name'];
             add_post_meta($account_id, '_wc_crm_customer_id', $customer_id);
         }
         $data = array('email' => $_POST['user_email'], 'first_name' => $_POST['first_name'], 'last_name' => $_POST['last_name'], 'state' => $_POST['_billing_state'], 'city' => $_POST['_billing_city'], 'country' => $_POST['_billing_country'], 'status' => $_POST['customer_status']);
         $res = $wpdb->update("{$wpdb->prefix}wc_crm_customer_list", $data, array('c_id' => $the_customer->customer_id));
         do_action('profile_update', $the_customer->user_id, $old_user_data);
         // update the post (may even be a revision / autosave preview)
         do_action('acf/save_post', 'user_' . $the_customer->user_id);
         do_action('acf/save_post', 'user_' . $the_customer->user_id);
         do_action('wc_crm_save_customer', $the_customer->customer_id, $the_customer, $old_user_data);
     } else {
         if ($the_customer->customer_id > 0) {
             $the_customer->init_general_fields();
             $disabled = array('first_name', 'last_name', 'user_email', 'customer_status');
             if ($the_customer->general_fields) {
                 foreach ($the_customer->general_fields as $key => $field) {
                     if (in_array($key, $disabled)) {
                         continue;
                     }
                     if (!isset($field['type'])) {
                         $field['type'] = 'text';
                     }
                     if (!isset($field['meta_key'])) {
                         $field['meta_key'] = $key;
                     }
                     if (!isset($_POST[$key])) {
//.........这里部分代码省略.........
开发者ID:daanbakker1995,项目名称:vanteun,代码行数:101,代码来源:class-wc-crm-screen-customers-edit.php

示例15: save

 function save($user_id, $new = false, $order = false)
 {
     if (!$order) {
         if (!empty($user_id) && !is_wp_error($user_id)) {
             $ID = (int) $user_id;
             $old_user_data = WP_User::get_data_by('id', $ID);
             $user_data_up = array('ID' => $user_id, 'user_url' => $_POST['customer_site']);
             $errors = new WP_Error();
             if (empty($_POST['user_email'])) {
                 $errors->add('empty_email', __('<strong>ERROR</strong>: Please enter an e-mail address.'), array('form-field' => 'user_email'));
             } elseif (!is_email($_POST['user_email'])) {
                 $errors->add('invalid_email', __('<strong>ERROR</strong>: The email address isn&#8217;t correct.'), array('form-field' => 'user_email'));
             } elseif (($owner_id = email_exists($_POST['user_email'])) && $owner_id != $user_id) {
                 $errors->add('email_exists', __('<strong>ERROR</strong>: This email is already registered, please choose another one.'), array('form-field' => 'user_email'));
             }
             $err = $errors->get_error_codes();
             if (!$err) {
                 $user_data_up['user_email'] = $_POST['user_email'];
                 $_SESSION['customer_save_errors'] = '';
             } else {
                 $_SESSION['customer_save_errors'] = $errors;
             }
             wp_update_user($user_data_up);
             $this->init_general_fields($user_id);
             if ($this->general_fields) {
                 foreach ($this->general_fields as $key => $field) {
                     if (!isset($field['type'])) {
                         $field['type'] = 'text';
                     }
                     if (!isset($field['meta_key'])) {
                         $field['meta_key'] = $key;
                     }
                     if (!isset($_POST[$key])) {
                         if ($field['type'] == 'multiselect') {
                             update_user_meta($user_id, $field['meta_key'], array());
                         }
                         continue;
                     }
                     switch ($key) {
                         case "customer_twitter":
                             $post_value = str_replace('@', '', $_POST['customer_twitter']);
                             break;
                         default:
                             $post_value = $_POST[$key];
                             break;
                     }
                     update_user_meta($user_id, $field['meta_key'], $post_value);
                 }
             }
             update_user_meta($user_id, 'preferred_payment_method', $_POST['_payment_method']);
             update_user_meta($user_id, 'billing_first_name', $_POST['_billing_first_name']);
             update_user_meta($user_id, 'billing_last_name', $_POST['_billing_last_name']);
             update_user_meta($user_id, 'billing_company', $_POST['_billing_company']);
             update_user_meta($user_id, 'billing_address_1', $_POST['_billing_address_1']);
             update_user_meta($user_id, 'billing_address_2', $_POST['_billing_address_2']);
             update_user_meta($user_id, 'billing_city', $_POST['_billing_city']);
             update_user_meta($user_id, 'billing_postcode', $_POST['_billing_postcode']);
             update_user_meta($user_id, 'billing_country', $_POST['_billing_country']);
             update_user_meta($user_id, 'billing_state', $_POST['_billing_state']);
             update_user_meta($user_id, 'billing_email', $_POST['_billing_email']);
             update_user_meta($user_id, 'billing_phone', $_POST['_billing_phone']);
             update_user_meta($user_id, 'payment_method', $_POST['_payment_method']);
             update_user_meta($user_id, 'shipping_first_name', $_POST['_shipping_first_name']);
             update_user_meta($user_id, 'shipping_last_name', $_POST['_shipping_last_name']);
             update_user_meta($user_id, 'shipping_company', $_POST['_shipping_company']);
             update_user_meta($user_id, 'shipping_address_1', $_POST['_shipping_address_1']);
             update_user_meta($user_id, 'shipping_address_2', $_POST['_shipping_address_2']);
             update_user_meta($user_id, 'shipping_city', $_POST['_shipping_city']);
             update_user_meta($user_id, 'shipping_postcode', $_POST['_shipping_postcode']);
             update_user_meta($user_id, 'shipping_country', $_POST['_shipping_country']);
             update_user_meta($user_id, 'shipping_state', $_POST['_shipping_state']);
             $group_ids = array();
             if (isset($_POST['wc_crm_customer_groups'])) {
                 $group_ids = $_POST['wc_crm_customer_groups'];
             }
             $user_email = $user_data_up['user_email'];
             wc_crm_update_user_groups($group_ids, $user_email);
             if (isset($_POST['account_name'])) {
                 $account_id = $_POST['account_name'];
                 add_post_meta($account_id, '_wc_crm_customer_email', $user_email);
             }
             // update the post (may even be a revision / autosave preview)
             do_action('acf/save_post', 'user_' . $user_id);
             do_action('acf/save_post', 'user_' . $user_id);
             do_action('profile_update', $user_id, $old_user_data);
             do_action('wc_crm_save_customer', $user_id, $old_user_data);
             if ($errors->get_error_codes()) {
                 var_dump($errors);
                 die;
                 return wp_redirect(add_query_arg(array("page" => "wc_new_customer", "user_id" => $user_id, "message" => 7), 'admin.php'));
             } elseif ($new) {
                 return wp_redirect(add_query_arg(array("page" => "wc-customer-relationship-manager", "message" => 1), 'admin.php'));
             } else {
                 return wp_redirect(add_query_arg(array("page" => "wc_new_customer", "user_id" => $user_id, "message" => 2), 'admin.php'));
             }
         } else {
             if (is_wp_error($user_id) && $user_id->get_error_codes()) {
                 $_SESSION['customer_save_errors'] = $user_id;
                 return wp_redirect(add_query_arg(array("page" => "wc_new_customer", "message" => 7), 'admin.php'));
             }
//.........这里部分代码省略.........
开发者ID:sajidshah,项目名称:le-dolci,代码行数:101,代码来源:wc_crm_customer_details.php


注:本文中的WP_User::get_data_by方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。