0

Is it possible to have a form in WordPress that would allow more than one user to register at a time? So say I wanted to be able to add 5 users at once, is this possible to do with the default registration form or is that limited to one user?

It would be one form (or multiple, but need all to submit at once) on the front-end that the user could add multiple emails to and it would set them up as subscribers and send out the generated password to each email listed. I can't figure out a way to add more than one at a time.

Would be using something similar to this, but with multiple users.

<form id="register-form" action="<?php echo site_url('wp-login.php?action=register', 'login_post') ?>" method="post">
    <input type="hidden" name="user_login" value="Username" id="user_login" class="input" />
    <input type="hidden" name="user_email" value="E-Mail" id="user_email" class="input"  />
    <?php do_action('register_form'); ?>
</form>

Any ideas? Thanks

3

1 Answer 1

1

Update

Found this awesome post http://tommcfarlin.com/create-a-user-in-wordpress/ that helped me solve the issue.

It was for a product in Shopp where a user can sign up multiple users for a training course, and each email needed to be registered as a subscriber.

This is the final code..

<?php
add_action( 'shopp_order_success', 'create_subscribers' );

function create_subscribers( $Purchase ) {

    foreach ( $Purchase->purchased as $purchase ) :

        $i = 1;
        while ( isset( $purchase->data['Email '.$i] ) ) :

            $email_address = $purchase->data['Email '.$i];

            if ( null == username_exists( $email_address ) ) :

                // Generate the password and create the user
                $password = wp_generate_password( 12, false );
                $user_id  = wp_create_user( $email_address, $password, $email_address );

                // Set the nickname
                wp_update_user(
                    array(
                        'ID'       =>    $user_id,
                        'nickname' =>    $email_address
                    )
                );

                // Set the role
                $user = new WP_User( $user_id );
                $user->set_role( 'subscriber' );

                // Email the user
                wp_mail( $email_address, 'Welcome!', 'Your Password: ' . $password );

            endif;
            $i++;
        endwhile;
    endforeach;
}

Your Answer

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

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