Have a wordpress theme with custom registration. Registration works on the registration page. If I take the form and place it on another page , eg. Homepage.. it gives me this error.
Here is the code for my form
// Form
<div class="container">
<?php if(edd_get_errors()){?>
<div class="error flash">
<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 flash">
<p><?php echo __( 'Thank you, You will receive your new password via email. For security, please change this upon login', 'forest' ); ?></p>
</div>
<?php }?>
<div class="content-s">
<div class="content-box">
<?php if (get_option('users_can_register')){ ?>
<form id="" class="horizontal-form" action="" method="post">
<fieldset>
<div class="input-group">
<label for="user_login"><?php echo __( 'Username', 'forest' ); ?>:</label>
<div class="inputs">
<input name="user_login" id="user_login" class="required" type="text" value="<?php echo isset($_POST['user_login']) ? esc_attr(stripslashes($_POST['user_login'])):''; ?>"/>
</div>
</div>
<div class="input-group">
<label for="user_email"><?php echo __( 'E-mail Addy', 'forest' ); ?>:</label>
<div class="inputs">
<input name="user_email" id="user_email" class="required" type="text" value="<?php echo isset($_POST['user_email']) ? esc_attr(stripslashes($_POST['user_email'])):''; ?>"/>
</div>
</div>
<div class="input-group">
<div class="inputs">
<em><?php echo __( 'The password will be e-mailed to you.', 'forest' ); ?></em>
</div>
</div>
<div class="form-submit">
<input type="hidden" name="edd_redirect" value="<?php bloginfo('url') ?>/wp-login.php?action=register&success=ok"/>
<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" class="btn-icon submit"><?php echo __( 'Create Account', 'forest' ); ?></button>
</div>
</fieldset>
</form>
<?php } else {?>
<h1><?php echo __('Registration is closed','forest'); ?></h1>
<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>
<?php }?>
</div>
</div>
</div>
and here is the code for the function
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' );
Full function code here
Why won't register_new_user() work if the form is placed anywhere else?
wp-includes/user.php
and should be available for any normal WP core load.wp-includes/user.php
was very recent. What version of WordPress are you using?