3

Is there a way to display the WordPress register form on a custom page the way one would use <?php get_search_form( $echo ); ?> for a search form? If not how would one go about creating such a template? I would like to do this without Ajax btw. Any pointers/ideas are very welcome!

2
3

Here is a function I've Used Before:

function registration_form_wpa95139(){
    if (is_user_logged_in()) return;
    ?>
    <div class="Registration">
        <div id="register-form">
            <div class="title">
                <h1><?php _e('Register your Account'); ?></h1>
                <span><?php _e('Sign Up with us and Enjoy!'); ?></span>
            </div>
            <form action="<?php echo site_url('wp-login.php?action=register', 'login_post') ?>" method="post">
                <input type="text" name="user_login" value="Username" id="user_login" class="input" placeholder="Username" />
                <input type="text" name="user_email" value="E-Mail" id="user_email" class="input"  placeholder="E-Mail" />
                    <?php do_action('register_form'); ?>
                    <input type="submit" value="<?php _e('Register'); ?>" id="register" />
                <hr />
                <p class="statement"><?php _e('A password will be e-mailed to you.'); ?></p>
            </form>
        </div>
    </div><!-- /Registration -->
    ?>
}

and you can call it like this:

<?php registration_form_wpa95139() ;?>
1
  • Thanks, this worked! One last thing, a handy redirection so it doesn't take the user backend. <input type="hidden" name="redirect_to" value="/success"/> – charlenemasters Apr 10 '13 at 9:53
0

Use this to redirect users to the page they were viewing before they were asked to log in/register <?php if (!is_user_logged_in()) auth_redirect(); ?>

Put it at the very top (line 1) of the page templates you want to make private before you call the header. Let me know if you have any problems.

1
  • Is it better to use that than <input type="hidden" name="redirect_to" value="/success"/> ? If yes why? – charlenemasters Apr 10 '13 at 11:25

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

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