當前位置: 首頁>>代碼示例>>PHP>>正文


PHP SwpmUtils::create_wp_user方法代碼示例

本文整理匯總了PHP中SwpmUtils::create_wp_user方法的典型用法代碼示例。如果您正苦於以下問題:PHP SwpmUtils::create_wp_user方法的具體用法?PHP SwpmUtils::create_wp_user怎麽用?PHP SwpmUtils::create_wp_user使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在SwpmUtils的用法示例。


在下文中一共展示了SwpmUtils::create_wp_user方法的4個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的PHP代碼示例。

示例1: register_admin_end

 public function register_admin_end()
 {
     //Check we are on the admin end and user has management permission
     SwpmMiscUtils::check_user_permission_and_is_admin('member creation by admin');
     //Check nonce
     if (!isset($_POST['_wpnonce_create_swpmuser_admin_end']) || !wp_verify_nonce($_POST['_wpnonce_create_swpmuser_admin_end'], 'create_swpmuser_admin_end')) {
         //Nonce check failed.
         wp_die(SwpmUtils::_("Error! Nonce verification failed for user registration from admin end."));
     }
     global $wpdb;
     $member = SwpmTransfer::$default_fields;
     $form = new SwpmForm($member);
     if ($form->is_valid()) {
         $member_info = $form->get_sanitized();
         $account_status = SwpmSettings::get_instance()->get_value('default-account-status', 'active');
         $member_info['account_state'] = $account_status;
         $plain_password = $member_info['plain_password'];
         unset($member_info['plain_password']);
         $wpdb->insert($wpdb->prefix . "swpm_members_tbl", $member_info);
         //Register to wordpress
         $query = $wpdb->prepare("SELECT role FROM " . $wpdb->prefix . "swpm_membership_tbl WHERE id = %d", $member_info['membership_level']);
         $wp_user_info = array();
         $wp_user_info['user_nicename'] = implode('-', explode(' ', $member_info['user_name']));
         $wp_user_info['display_name'] = $member_info['user_name'];
         $wp_user_info['user_email'] = $member_info['email'];
         $wp_user_info['nickname'] = $member_info['user_name'];
         if (isset($member_info['first_name'])) {
             $wp_user_info['first_name'] = $member_info['first_name'];
         }
         if (isset($member_info['last_name'])) {
             $wp_user_info['last_name'] = $member_info['last_name'];
         }
         $wp_user_info['user_login'] = $member_info['user_name'];
         $wp_user_info['password'] = $plain_password;
         $wp_user_info['role'] = $wpdb->get_var($query);
         $wp_user_info['user_registered'] = date('Y-m-d H:i:s');
         SwpmUtils::create_wp_user($wp_user_info);
         //End register to wordpress
         //Send notification
         $send_notification = SwpmSettings::get_instance()->get_value('enable-notification-after-manual-user-add');
         $member_info['plain_password'] = $plain_password;
         $this->member_info = $member_info;
         if (!empty($send_notification)) {
             $this->send_reg_email();
         }
         $message = array('succeeded' => true, 'message' => '<p>' . SwpmUtils::_('Member record added successfully.') . '</p>');
         SwpmTransfer::get_instance()->set('status', $message);
         wp_redirect('admin.php?page=simple_wp_membership');
         exit(0);
     }
     $message = array('succeeded' => false, 'message' => SwpmUtils::_('Please correct the following:'), 'extra' => $form->get_errors());
     SwpmTransfer::get_instance()->set('status', $message);
 }
開發者ID:jesusmarket,項目名稱:jesusmarket,代碼行數:53,代碼來源:class.swpm-admin-registration.php

示例2: register

 public function register()
 {
     global $wpdb;
     $member = SwpmTransfer::$default_fields;
     $form = new SwpmForm($member);
     if ($form->is_valid()) {
         $member_info = $form->get_sanitized();
         $account_status = SwpmSettings::get_instance()->get_value('default-account-status', 'active');
         $member_info['account_state'] = $account_status;
         $plain_password = $member_info['plain_password'];
         unset($member_info['plain_password']);
         $wpdb->insert($wpdb->prefix . "swpm_members_tbl", $member_info);
         /*             * ******************** register to wordpress ********** */
         $query = $wpdb->prepare("SELECT role FROM " . $wpdb->prefix . "swpm_membership_tbl WHERE id = %d", $member_info['membership_level']);
         $wp_user_info = array();
         $wp_user_info['user_nicename'] = implode('-', explode(' ', $member_info['user_name']));
         $wp_user_info['display_name'] = $member_info['user_name'];
         $wp_user_info['user_email'] = $member_info['email'];
         $wp_user_info['nickname'] = $member_info['user_name'];
         if (isset($member_info['first_name'])) {
             $wp_user_info['first_name'] = $member_info['first_name'];
         }
         if (isset($member_info['last_name'])) {
             $wp_user_info['last_name'] = $member_info['last_name'];
         }
         $wp_user_info['user_login'] = $member_info['user_name'];
         $wp_user_info['password'] = $plain_password;
         $wp_user_info['role'] = $wpdb->get_var($query);
         $wp_user_info['user_registered'] = date('Y-m-d H:i:s');
         SwpmUtils::create_wp_user($wp_user_info);
         /*             * ******************** register to wordpress ********** */
         $send_notification = SwpmSettings::get_instance()->get_value('enable-notification-after-manual-user-add');
         $member_info['plain_password'] = $plain_password;
         $this->member_info = $member_info;
         if (!empty($send_notification)) {
             $this->send_reg_email();
         }
         $message = array('succeeded' => true, 'message' => '<p>' . SwpmUtils::_('Member record added successfully.') . '</p>');
         SwpmTransfer::get_instance()->set('status', $message);
         wp_redirect('admin.php?page=simple_wp_membership');
         exit(0);
     }
     $message = array('succeeded' => false, 'message' => SwpmUtils::_('Please correct the following:'), 'extra' => $form->get_errors());
     SwpmTransfer::get_instance()->set('status', $message);
 }
開發者ID:AndroidScriptAS,項目名稱:bismarck_smv,代碼行數:45,代碼來源:class.swpm-admin-registration.php

示例3: create_wp_user

 private function create_wp_user()
 {
     global $wpdb;
     $member_info = $this->member_info;
     $query = $wpdb->prepare("SELECT role FROM " . $wpdb->prefix . "swpm_membership_tbl WHERE id = %d", $member_info['membership_level']);
     $wp_user_info = array();
     $wp_user_info['user_nicename'] = implode('-', explode(' ', $member_info['user_name']));
     $wp_user_info['display_name'] = $member_info['user_name'];
     $wp_user_info['user_email'] = $member_info['email'];
     $wp_user_info['nickname'] = $member_info['user_name'];
     $wp_user_info['first_name'] = $member_info['first_name'];
     $wp_user_info['last_name'] = $member_info['last_name'];
     $wp_user_info['user_login'] = $member_info['user_name'];
     $wp_user_info['password'] = $member_info['plain_password'];
     $wp_user_info['role'] = $wpdb->get_var($query);
     $wp_user_info['user_registered'] = date('Y-m-d H:i:s');
     SwpmUtils::create_wp_user($wp_user_info);
     return true;
 }
開發者ID:andrewfieldwmg,項目名稱:greenschoolsproject,代碼行數:19,代碼來源:class.swpm-front-registration.php

示例4: prepare_and_create_wp_user_front_end

 private function prepare_and_create_wp_user_front_end()
 {
     global $wpdb;
     $member_info = $this->member_info;
     //Retrieve the user role assigned for this level
     $query = $wpdb->prepare("SELECT role FROM " . $wpdb->prefix . "swpm_membership_tbl WHERE id = %d", $member_info['membership_level']);
     $user_role = $wpdb->get_var($query);
     //Check to make sure that the user role of this level is not admin.
     if ($user_role == 'administrator') {
         //For security reasons we don't allow users with administrator role to be creted from the front-end. That can only be done from the admin dashboard side.
         $error_msg = '<p>Error! The user role for this membership level (level ID: ' . $member_info['membership_level'] . ') is set to "Administrator".</p>';
         $error_msg .= '<p>For security reasons, member registration to this level is not permitted from the front end.</p>';
         $error_msg .= '<p>An administrator of the site can manually create a member record with this access level from the admin dashboard side.</p>';
         wp_die($error_msg);
     }
     $wp_user_info = array();
     $wp_user_info['user_nicename'] = implode('-', explode(' ', $member_info['user_name']));
     $wp_user_info['display_name'] = $member_info['user_name'];
     $wp_user_info['user_email'] = $member_info['email'];
     $wp_user_info['nickname'] = $member_info['user_name'];
     $wp_user_info['first_name'] = $member_info['first_name'];
     $wp_user_info['last_name'] = $member_info['last_name'];
     $wp_user_info['user_login'] = $member_info['user_name'];
     $wp_user_info['password'] = $member_info['plain_password'];
     $wp_user_info['role'] = $user_role;
     $wp_user_info['user_registered'] = date('Y-m-d H:i:s');
     SwpmUtils::create_wp_user($wp_user_info);
     return true;
 }
開發者ID:jesusmarket,項目名稱:jesusmarket,代碼行數:29,代碼來源:class.swpm-front-registration.php


注:本文中的SwpmUtils::create_wp_user方法示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。