本文整理汇总了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);
}
示例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);
}
示例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;
}
示例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;
}