我有一个来自模板的自定义注册表单,它可以正常工作。但是,当我将注册表单放入模式中时,在主页上它会吐出错误。
致命错误:在第 40 行调用 C:\wamp\www\mysite\wp-content\themes\mysite\functions\theme-access.php 中未定义的函数 register_new_user()
我已经复制了注册中的所有项目,但它无法正常工作。我需要为wordpress添加一些东西来做到这一点吗?下面是我的注册表单的代码片段。
<div class="modal-body">
<div class="span3">
<!-- messages -->
<?php if(edd_get_errors()){?>
<div class="alert alert-danger">
<p><?php __( 'Please review the following issues that occurred', 'forest' ); ?></p>
<ul>
<?php forest_print_errors();?>
</ul>
</div>
<?php } else if(isset($_GET['success']) && $_GET['success'] == "ok") {?>
<div class="success alert alert-success">
<p><?php echo __( 'Thank you for signing up! You will receive your password via email', 'forest' ); ?></p>
</div>
<?php }?>
<?php if (get_option('users_can_register')){ ?>
<!-- end messages -->
<form id="registre_form" action="" method="post">
<div class="span3">
<label><?php echo __( 'Username', 'forest' ); ?>:</label>
<input type="text" name="firstname" class="span3" name="user_login" id="user_login" value="<?php echo isset($_POST['user_login']) ? esc_attr(stripslashes($_POST['user_login'])):''; ?>">
<label><?php echo __( 'E-mail Addy', 'forest' ); ?>:</label>
<input type="email" name="email" class="span3" name="user_email" id="user_email" value="<?php echo isset($_POST['user_email']) ? esc_attr(stripslashes($_POST['user_email'])):''; ?>"/>
<span class="label label-warning">Your password will be emailed to you.</span>
<input type="hidden" name="edd_redirect" value="<?php bloginfo('url') ?>"/>
<input type="hidden" name="edd-registre-nonce" value="<?php echo wp_create_nonce( 'edd-registre-nonce' ); ?>"/>
<input type="hidden" name="edd_action" value="user_registre"/>
<button type="submit" value="Sign up" class="btn btn-warning pull-right"><?php echo __( 'Sign Up', 'forest' ); ?></button>
<div class="clearfix"></div>
</form>
</div>
<?php } else {?>
<div class="span3">
<h3><?php echo __('Registration is closed','forest'); ?></h3>
<p><?php echo __('Sorry, you are not allowed to register by yourself on this site!','forest'); ?></p>
<p><?php echo __('You must either be invited by one of our team member or request an invitation by email.','forest'); ?></p>
</div>
<?php }?>
</div>
这是导致错误的功能
/**
* Process registre Form
* @param array $data Data sent from the reset login form
* @return void
*/
function forest_process_registre_form( $data ) {
if ( wp_verify_nonce( $data['edd-registre-nonce'], 'edd-registre-nonce' ) ) {
$errors = register_new_user($data['user_login'], $data['user_email']);
if ( isset($errors) && is_array($errors) ){
foreach($errors as $error) {
if(count($error) > 0) {
foreach($error as $e) {
edd_set_error( 'email_incorrect', $e[0]);
}
}
}
}
// Check for errors and redirect if none present
$errors = edd_get_errors();
if ( ! $errors ) {
$redirect = apply_filters( 'edd_login_redirect', $data['edd_redirect'], $user_ID );
wp_redirect( $redirect );
exit;
}
}
}
add_action( 'edd_user_registre', 'forest_process_registre_form' );