3

I googled about customizing wp-signup.php but found no luck. Here's what I need:

  1. User will register.
  2. During registration process, user will pay first (like paypal or credit card).
  3. Create subdomain when user successfully paid.

My problem is: How can I add a payment field in wp-signup.php? I am really new to wordpress. Any guide or link is a big help to me.

Registration form something like this:

  • username
  • email address
  • gimme a site
  • payment
  • register button
4
  • 1
    But do you know how to program? In PHP, for instance.
    – brasofilo
    Commented Nov 20, 2012 at 9:38
  • 1
    Yeah I know how to program PHP. But I'm new to CMS.
    – jayellos
    Commented Nov 20, 2012 at 9:43
  • There is good tutorial here. Check this out tutorialstag.com/create-custom-wordpress-registration-page.html
    – Mubbashar
    Commented Nov 20, 2012 at 13:10
  • I looked for this once and to the best of my knowledge there isn't anything available that requires the user the pay first. I think the hold up is that you can't add any billing info to a user until WP has an actual user record. I'll be interested to see what you come up with. Commented Apr 3, 2013 at 14:47

1 Answer 1

4

The register form have different hooks for custom fields.

I hope this source example help you.

    /**
     * Add custom field to registration form
     */
    add_action( 'register_form', 'fb_show_first_name_field' );
    add_action( 'register_post', 'fb_check_fields', 10, 3 );
    add_action( 'user_register', 'fb_register_extra_fields' );

    function fb_show_first_name_field() {
    ?>
        <p>
            <label>Twitter<br/>
                <input id="twitter" type="text" tabindex="30" size="25" value="<?php echo $_POST['twitter']; ?>" name="twitter" />
            </label>
        </p>
    <?php
    }

    function fb_check_fields ( $login, $email, $errors ) {
        global $twitter;

        if ( '' === $_POST['twitter'] )
            $errors->add( 'empty_realname', "<strong>ERROR</strong>: Please Enter your twitter handle" );
        else
            $twitter = $_POST['twitter'];

    }

    function fb_register_extra_fields ( $user_id, $password = "", $meta = array() ) {

        update_user_meta( $user_id, 'twitter', $_POST['twitter'] );
    }

It is also usefull, I think, that you add the fields to the rpofile page for changes and view of the field content.

    /**
     * Add additional custom field
     */
    add_action( 'show_user_profile', 'fb_show_extra_profile_fields' );
    add_action( 'edit_user_profile', 'fb_show_extra_profile_fields' );

    function fb_show_extra_profile_fields( $user ) {
    ?>
        <h3>Extra profile information</h3>
        <table class="form-table">
            <tr>
                <th><label for="twitter">Twitter</label></th>
                <td>
                    <input type="text" name="twitter" id="twitter" value="<?php echo esc_attr( get_the_author_meta( 'twitter', $user->ID ) ); ?>" class="regular-text" /><br />
                    <span class="description">Please enter your Twitter username.</span>
                </td>
            </tr>
        </table>
    <?php
    }

    add_action( 'personal_options_update',  'fb_save_extra_profile_fields' );
    add_action( 'edit_user_profile_update', 'fb_save_extra_profile_fields' );
    function fb_save_extra_profile_fields( $user_id ) {

        if ( ! current_user_can( 'edit_user', $user_id ) )
            return FALSE;

        /* Copy and paste this line for additional fields. Make sure to change 'twitter' to the field ID. */
        update_user_meta( $user_id, 'twitter', $_POST['twitter'] );
    }
1
  • I am using WordPress multisite subdirectory and subdomain. The register_form and register_post hooks do not work =( I wanted to customize the registration page but those hooks are not called in WP multisite.
    – user42826
    Commented Jan 17, 2014 at 1:44

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.