latest stable versions: v150827 (changelog)

Old Forums (READ-ONLY): The community now lives at WP Sharks™. If you have an s2Member® Pro question, please use our new Support System.

Import fails users without email address

Home Forums Community Forum Import fails users without email address

This topic contains 5 replies, has 2 voices. Last updated by  Cristián Lávaque 3 years, 6 months ago.

Topic Author Topic
Posted: Tuesday Jun 18th, 2013 at 7:35 pm #52161
bigdata
Username: ffawebmgr

How do we import members without emails?

Wordpress does not require an email:
Codex wp_create_user

This appears to be an artificial restriction of the s2 import.

List Of Topic Replies

Viewing 5 replies - 1 through 5 (of 5 total)
Author Replies
Author Replies
Posted: Wednesday Jun 19th, 2013 at 7:11 am #52202

It’s the first time I see the email could be optional. When you register an account in your WordPress, without s2Member, using the default registration form, can you do it without an email address?

I’ll ask Jason about this, too.

Posted: Wednesday Jun 19th, 2013 at 8:52 pm #52250
bigdata
Username: ffawebmgr

I am confused by your question. What does the default registration form have to do with the s2member import function? If we wanted the default functionality, we would not be trying out your premium software.

We need to import users without email addresses. It is clear that WordPress add_user allows it, as we have done it. It is also clear that others want to do this too.

Can do we do it with your import function? If not now, would you consider making it an option or adding a hook?

Posted: Thursday Jun 20th, 2013 at 3:13 am #52278

This is what Jason replied answering your question:

Yes, email addresses are required. WordPress is not great about setting standards and following them in all places. While the DB design suggests that emails are not required, and some functions follow that standard; other areas of the WordPress core DO require an email address; and many areas of the WP core expect an email address to be present (as if the DB were designed that way; e.g. to require one). So it’s confusing, I know. But once you’ve worked with WordPress for awhile you will find that WordPress really does require an email address for each user. Also, that just makes sense. I mean, how do you contact someone that’s a user of your site if you don’t have their email address?

Plugins for WP also expect an email address to be present for each user.

Here is a snippet from the WordPress core that requires an email address: /wp-login.php

function register_new_user( $user_login, $user_email ) {
    $errors = new WP_Error();

    $sanitized_user_login = sanitize_user( $user_login );
    $user_email = apply_filters( 'user_registration_email', $user_email );

    // Check the username
    if ( $sanitized_user_login == '' ) {
        $errors->add( 'empty_username', __( '<strong>ERROR</strong>: Please enter a username.' ) );
    } elseif ( ! validate_username( $user_login ) ) {
        $errors->add( 'invalid_username', __( '<strong>ERROR</strong>: This username is invalid because it uses illegal characters. Please enter a valid username.' ) );
        $sanitized_user_login = '';
    } elseif ( username_exists( $sanitized_user_login ) ) {
        $errors->add( 'username_exists', __( '<strong>ERROR</strong>: This username is already registered. Please choose another one.' ) );
    }

    // Check the e-mail address
    if ( $user_email == '' ) {
        $errors->add( 'empty_email', __( '<strong>ERROR</strong>: Please type your e-mail address.' ) );
    } elseif ( ! is_email( $user_email ) ) {
        $errors->add( 'invalid_email', __( '<strong>ERROR</strong>: The email address isn&#8217;t correct.' ) );
        $user_email = '';
    } elseif ( email_exists( $user_email ) ) {
        $errors->add( 'email_exists', __( '<strong>ERROR</strong>: This email is already registered, please choose another one.' ) );
    }

If users are being imported (and the site owner has no email address for them); I suggest using a dummy email address instead (e.g. user1@example.com). Or, they can modify the source code in this file to NOT require an email address if they prefer. See: /s2member-pro/includes/classes/imports.inc.php

Posted: Thursday Jun 20th, 2013 at 8:46 pm #52310
bigdata
Username: ffawebmgr

If you examine the code a little more, you will find that there is a hook ‘user_profile_update_errors’ which allows you to add or REMOVE error messages with a few simple lines of code. This can be applied to almost everything but username & password – the only 2 items that are actually required.

I have 2 sites running WordPress that do not require email addresses for users.

There are other plugins, some free in the directory and some premium, which allow this option.

I already understand we can hack “imports.inc.php”, but we would prefer you consider this as an option in dashboard or an api hook similar to the way WordPress does it the future.

This would be better for our many clients that we are considering s2 for.

Posted: Saturday Jun 22nd, 2013 at 6:30 am #52374

We’ll consider it. Added it to the feature requests. Thanks for the feedback!

Viewing 5 replies - 1 through 5 (of 5 total)

This topic is closed to new replies. Topics with no replies for 2 weeks are closed automatically.

Old Forums (READ-ONLY): The community now lives at WP Sharks™. If you have an s2Member® Pro question, please use our new Support System.

Contacting s2Member: Please use our Support Center for bug reports, pre-sale questions & technical assistance.