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>
                      <?php forest_print_errors();?>
                <?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>
                <?php }?>
                <div class="content-s">
                     <div class="content-box">
                        <?php if (get_option('users_can_register')){ ?>

                                        <form id=""  class="horizontal-form" action="" method="post">

                                                        <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 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 class="input-group">
                                                                <div class="inputs">
                                                                 <em><?php echo __( 'The password will be e-mailed to you.', 'forest' ); ?></em>

                                                        <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>


                                <?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 }?>


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 );
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?

  • Are you doing anytning atypical with load there? The function is defined in wp-includes/user.php and should be available for any normal WP core load.
    – Rarst
    Sep 15, 2013 at 14:04
  • The move to wp-includes/user.php was very recent. What version of WordPress are you using?
    – s_ha_dum
    Sep 15, 2013 at 14:15
  • @s_ha_dum I am using wp version 3.6 at the moment. Sep 15, 2013 at 14:23
  • @Rarst Not that I am aware of. I know the function is deprecated. But the registation runs fine on the page with url 'wp-login.php?action=register' its only when I take the form I have outside of that page it breaks. I want to have a register modal in the header so a user can quickly register. Why it doesn't register is outside baffles me. Sep 15, 2013 at 14:28

1 Answer 1


I greped a 3.6 install and got this:

./wp-login.php:321:function register_new_user( $user_login, $user_email ) {
./wp-login.php:550:             $errors = register_new_user($user_login, $user_email);

Notice the function definition is in wp-login.php.

If you look at the current wp-login.php, it isn't there anymore and there is a note at the top of the page, just above the code:

Last change on this file was 25231, checked in by SergeyBiryukov, 11 days ago

Move check_password_reset_key(), reset_password(), and register_new_user() from wp-login.php to wp-includes/user.php, to make them reusable. props beaulebens for initial patch. fixes #20279.

That migration of code has been needed for a long, long time. I am glad it was finally done. Your fix is to update WordPress.

  • Very interesting. I have upgraded to 3.6.1, yet I still get th error Call to undefined function register_new_user() This is inside a themes custom function file. So can the function be called if its outside wp-login.php. The fix you listed makes perfect sense why it is doing that but it still fails to process the registration. Sep 15, 2013 at 14:39
  • Do you have any caching on the site?
    – s_ha_dum
    Sep 15, 2013 at 14:52
  • I have cleared the cache. However I have downloaded the latest version manually and found that 'register_new_user' still exists in wp-login.php even though it has meant to have migrated to wp-includes/user.php. So they haven't included it in 3.6.1! Shall I just move the code manually? If so, am I just moving that function to user.php? Sep 15, 2013 at 15:19
  • The subversion release should have the latest patches.
    – s_ha_dum
    Sep 15, 2013 at 15:26
  • Thankyou so much! This has fixed the issue. How you found that and resolved the issue is amazing, you rock! Sep 15, 2013 at 15:47

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.