0

I've been reading around and looking for a front-end signup form (not using plugins!) and came across this - http://net.tutsplus.com/tutorials/wordpress/quick-tip-making-a-fancy-wordpress-register-form-from-scratch/

    <div id="register-form">
    <div class="title">
        <h1>Register your Account</h1>
        <span>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" />
        <input type="text" name="user_email" value="E-Mail" id="user_email" class="input"  />
            <?php do_action('register_form'); ?>
            <input type="submit" value="Register" id="register" />
        <hr />
        <p class="statement">A password will be e-mailed to you.</p>


        </form>
    </div>

It's almost everything I need but there are a few things missing in terms of the fields. Is it possible to add extra fields to the front end signup form that will be saved in and displayed in the backend?

5
  • Please show your code, your effort/what you tried and what's not working.
    – kaiser
    Commented Sep 3, 2012 at 15:09
  • @kaiser I'm using the tutorial at the moment and looking around how to add custom fields, so that's where I am at the moment.
    – Rob
    Commented Sep 3, 2012 at 15:17
  • So what's the problem with showing your current state with code?
    – kaiser
    Commented Sep 3, 2012 at 15:25
  • @kaiser Updated question... it's straight from the tutorial at the moment.
    – Rob
    Commented Sep 3, 2012 at 15:27
  • Please search the site, try something and report with something like "this doesn't work for me, because of (...)". Thanks.
    – kaiser
    Commented Sep 3, 2012 at 16:24

1 Answer 1

1

You can read a somewhat extensive tutorial over at:

http://www.cozmoslabs.com/1012-wordpress-user-registration-template-and-custom-user-profile-fields/

Basically this is what you're going to be using to add them to the backend:

add_action( 'show_user_profile', 'show_extra_profile_fields', 10 );
add_action( 'edit_user_profile', 'show_extra_profile_fields', 10 );

function show_extra_profile_fields( $user ) { ?>
    <input type="text" name="twitter" value="<?php echo esc_attr( get_the_author_meta( 'twitter', $user->ID ) ); ?>" />
<?php }

and to save them when the user or admin updates the profile:

add_action( 'personal_options_update', 'save_extra_profile_fields' );
add_action( 'edit_user_profile_update', 'save_extra_profile_fields' );

function save_extra_profile_fields( $user_id ) {
    if ( !current_user_can( 'edit_user', $user_id ) )
        return false;
    update_usermeta( $user_id, 'twitter', $_POST['twitter'] );
}

Next step is to add/save these extra fields to the form you're building and use:

update_usermeta( $new_user, 'twitter', esc_attr( $_POST['twitter']  ) );    

to save them from the front-end when the user registers.

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.