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
  • It's an old plugin, but this -- dagondesign.com/articles/import-users-plugin-for-wordpress -- has worked for me in the past.
    – Pat J
    Commented Jul 11, 2013 at 21:40
  • Looks like that is just for the backend, trying to figure out a way to be able to do it on the front-end. Thanks though
    – ferne97
    Commented Jul 11, 2013 at 22:04
  • Gotcha, moved it to an answer
    – ferne97
    Commented Jul 12, 2013 at 3:59

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 you have read our privacy policy.

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