Php 在wordpress注册中隐藏用户名
我正在寻找一种更好的方法来隐藏wordpress注册表上的用户名。目前,我已经让它工作,但它不是用户友好的形式将重新要求注册者“请键入您的电子邮件地址”(即使他们已经这样做)。这可以在电视上看到 下面是我的代码的上半部分:Php 在wordpress注册中隐藏用户名,php,wordpress,Php,Wordpress,我正在寻找一种更好的方法来隐藏wordpress注册表上的用户名。目前,我已经让它工作,但它不是用户友好的形式将重新要求注册者“请键入您的电子邮件地址”(即使他们已经这样做)。这可以在电视上看到 下面是我的代码的上半部分: <?php $current_email = isset($_POST['user_email']) ? $_POST['user_email'] : ''; $current_username = $current_email; ?> <?php if
<?php
$current_email = isset($_POST['user_email']) ? $_POST['user_email'] : '';
$current_username = $current_email;
?>
<?php if ($this->should_print_form()) : ?>
<?php $this->print_form_header(); ?>
<div class="row clearfix">
<div class="col-sm-10 col-md-8 col-sm-offset-1 col-md-offset-2">
<div class="panel panel-primary panel-border top">
<div class="panel-heading">
<span class="panel-title fs-lg"><i class="fa fa-edit"></i> <?php _e('Create an account', 'cuarlf'); ?></span>
</div>
<div class="panel-body">
<div class="form-group mb-lg">
<label for="user_email" class="control-label top-label"><?php _e('Email Address', 'cuarlf'); ?></label>
<div class="row clearfix">
<div class="col-xs-12">
<span class="append-icon right"><i class="field-icon fa fa-asterisk text-muted"></i></span>
<input class="form-control" type="email" name="user_email" id="user_email" value="<?php echo esc_attr($current_email); ?>">
<input class="form-control" type="hidden" name="user_login" id="user_login" value="<?php echo $current_username; ?>">
</div>
</div>
</div>
我想得太多了
对于表单,您需要做的全部工作就是为user_login输入一个伪值,以便它看起来像:
在页面顶部,我删除了$current\u username=$current\u email代码>
在表单提交代码中,我让表单使用$\u POST['user\u email']
作为用户登录值
if (isset($_POST['user_email']))
{
$user_email = $_POST['user_email'];
$user_login = $_POST['user_email'];
// Check captch if enabled
if (class_exists("ReallySimpleCaptcha"))
{
$captcha_instance = new ReallySimpleCaptcha();
if ( !isset($_POST['cuar_captcha_prefix']) || !isset($_POST['captcha']))
{
$this->form_errors[] = new WP_Error('captcha',
__("You must write the code displayed in the image above.", 'cuarlf'));
return;
}
else
{
$prefix = $_POST['cuar_captcha_prefix'];
$code = $_POST['captcha'];
$captcha_checked = $captcha_instance->check($prefix, $code);
$captcha_instance->remove($prefix);
$captcha_instance->cleanup();
if ( !$captcha_checked)
{
$this->form_errors[] = new WP_Error('captcha', __("The code you entered is not correct.", 'cuarlf'));
return;
}
}
}
$errors = CUAR_WPLoginHelper::register_new_user($user_login, $user_email);
if (is_wp_error($errors))
{
$this->form_errors[] = $errors;
return;
}
}
else
{
$this->form_errors[] = new WP_Error('user_login', __("You must enter a valid username and a valid email address.", 'cuarlf'));
return;
}
$lf_addon = $this->plugin->get_addon('login-forms');
$this->form_messages[] = sprintf(__('An email has been sent with the instructions to activate your account. '
. 'You can then go to the <a href="%1$s" class="alert-link">login page</a>', 'cuarlf'), $lf_addon->get_login_url());
$this->should_print_form = false;
}
if(设置($\u POST['user\u email']))
{
$user\u email=$\u POST['user\u email'];
$user\u login=$\u POST['user\u email'];
//如果启用,请检查captch
如果(类_存在(“ReallySimpleCaptcha”))
{
$captcha_instance=new ReallySimpleCaptcha();
如果(!isset($_POST['cuar\u captcha\u prefix']))| |!isset($_POST['captcha']))
{
$this->form_errors[]=新的WP_Error('captcha',
__(“您必须编写上图中显示的代码。”,“cuarlf”);
返回;
}
其他的
{
$prefix=$\u POST['cuar\u captcha\u prefix'];
$code=$_POST['captcha'];
$captcha\u checked=$captcha\u实例->检查($prefix,$code);
$captcha\u实例->删除($prefix);
$captcha_实例->清理();
如果(!$captcha\u已选中)
{
$this->form_errors[]=new WP_Error('captcha',uuuu(“您输入的代码不正确。”,'cuarlf'));
返回;
}
}
}
$errors=CUAR\u WPLoginHelper::register\u new\u user($user\u login,$user\u email);
如果(是错误($errors))
{
$this->form_errors[]=$errors;
返回;
}
}
其他的
{
$this->form_errors[]=new WP_Error('user_login',uuu(“您必须输入有效的用户名和电子邮件地址。”,'cuarlf'));
返回;
}
$lf_addon=$this->plugin->get_addon('login-forms');
$this->form_messages[]=sprintf(uuuu('已发送一封电子邮件,说明如何激活您的帐户。'
'然后您可以转到''cuarlf'),$lf\u加载项->获取\u登录\u url());
$this->should\u print\u form=false;
}
我想得太多了
对于表单,您需要做的全部工作就是为user_login输入一个伪值,以便它看起来像:
在页面顶部,我删除了$current\u username=$current\u email代码>
在表单提交代码中,我让表单使用$\u POST['user\u email']
作为用户登录值
if (isset($_POST['user_email']))
{
$user_email = $_POST['user_email'];
$user_login = $_POST['user_email'];
// Check captch if enabled
if (class_exists("ReallySimpleCaptcha"))
{
$captcha_instance = new ReallySimpleCaptcha();
if ( !isset($_POST['cuar_captcha_prefix']) || !isset($_POST['captcha']))
{
$this->form_errors[] = new WP_Error('captcha',
__("You must write the code displayed in the image above.", 'cuarlf'));
return;
}
else
{
$prefix = $_POST['cuar_captcha_prefix'];
$code = $_POST['captcha'];
$captcha_checked = $captcha_instance->check($prefix, $code);
$captcha_instance->remove($prefix);
$captcha_instance->cleanup();
if ( !$captcha_checked)
{
$this->form_errors[] = new WP_Error('captcha', __("The code you entered is not correct.", 'cuarlf'));
return;
}
}
}
$errors = CUAR_WPLoginHelper::register_new_user($user_login, $user_email);
if (is_wp_error($errors))
{
$this->form_errors[] = $errors;
return;
}
}
else
{
$this->form_errors[] = new WP_Error('user_login', __("You must enter a valid username and a valid email address.", 'cuarlf'));
return;
}
$lf_addon = $this->plugin->get_addon('login-forms');
$this->form_messages[] = sprintf(__('An email has been sent with the instructions to activate your account. '
. 'You can then go to the <a href="%1$s" class="alert-link">login page</a>', 'cuarlf'), $lf_addon->get_login_url());
$this->should_print_form = false;
}
if(设置($\u POST['user\u email']))
{
$user\u email=$\u POST['user\u email'];
$user\u login=$\u POST['user\u email'];
//如果启用,请检查captch
如果(类_存在(“ReallySimpleCaptcha”))
{
$captcha_instance=new ReallySimpleCaptcha();
如果(!isset($_POST['cuar\u captcha\u prefix']))| |!isset($_POST['captcha']))
{
$this->form_errors[]=新的WP_Error('captcha',
__(“您必须编写上图中显示的代码。”,“cuarlf”);
返回;
}
其他的
{
$prefix=$\u POST['cuar\u captcha\u prefix'];
$code=$_POST['captcha'];
$captcha\u checked=$captcha\u实例->检查($prefix,$code);
$captcha\u实例->删除($prefix);
$captcha_实例->清理();
如果(!$captcha\u已选中)
{
$this->form_errors[]=new WP_Error('captcha',uuuu(“您输入的代码不正确。”,'cuarlf'));
返回;
}
}
}
$errors=CUAR\u WPLoginHelper::register\u new\u user($user\u login,$user\u email);
如果(是错误($errors))
{
$this->form_errors[]=$errors;
返回;
}
}
其他的
{
$this->form_errors[]=new WP_Error('user_login',uuu(“您必须输入有效的用户名和电子邮件地址。”,'cuarlf'));
返回;
}
$lf_addon=$this->plugin->get_addon('login-forms');
$this->form_messages[]=sprintf(uuuu('已发送一封电子邮件,说明如何激活您的帐户。'
'然后您可以转到''cuarlf'),$lf\u加载项->获取\u登录\u url());
$this->should\u print\u form=false;
}
这是我尝试的功能,但没有成功-这是我尝试的功能,但没有成功-