• Resolved inzerat

    (@inzerat)


    using an email address as login is not smart, just imagine you will loose the email account and you can’t recover the password because teh mail is send to the old email address. Its confusing for users… please you can do normal username when user check the checkbox “Create an account for me so I can manage all my ads from one place (password will be emailed to you) or Sign In” when posting ad?

Viewing 4 replies - 1 through 4 (of 4 total)
  • Thread Starter inzerat

    (@inzerat)

    core of wordpress have normal username, woocomerce have normal username, bbpress have normal username…

    why wp adverts plugin automatic created username as email?

    Thread Starter inzerat

    (@inzerat)

    next issues is security reason, email as login is with conflict with philosophy of wordpress

    Plugin Author Greg Winiarski

    (@gwin)

    using an email address as login is not smart, just imagine you will lose the email account and you can’t recover the password because the mail is sent to the old email address.

    How does having a username help with this? The password recovery email will still be sent to the email address you have lost.

    email as login is with conflict with philosophy of wordpress

    How so? WordPress itself allows to login with both username and email.

    WPAdverts uses email as login as this is one thing less for users to think about. This is actually a common trend among all websites you no longer need to come up with your own login, just the email address will do.

    Either way, to allow users to have a username set you can add the code below in your theme functions.php file, it will add the username field and use it when registering a user

    
    add_action( "init", "my_username_init", 100 );
    function my_username_init() {
        remove_filter('adverts_create_user_from_post_id', '_adverts_create_user_from_post_id', 20, 2 );
        add_filter('adverts_create_user_from_post_id', '_my_username_create_user_from_post_id', 20, 2 );
        add_filter('adverts_form_load', 'adverts_add_username_field' );
    }
    function _my_username_create_user_from_post_id( $user_id, $post_id ) {
        
        if( $user_id !== null ) {
            // some other filter already registered user, skip registration then
            return $user_id;
        }
        
        $email_address = get_post_meta( $post_id, "adverts_email", true );
        $username = get_post_meta( $post_id, "my_username", true );
        $full_name = get_post_meta( $post_id, "adverts_person", true );
        // Generate the password and create the user
        $password = wp_generate_password( 12, false );
        $user_id = wp_create_user( $username, $password, $email_address );
    
        // Set the nickname
        wp_update_user(
            array(
                'ID'          =>    $user_id,
                'nickname'    =>    $full_name,
                'display_name'=>    $full_name
            )
        );
    
        // Set the role
        $user = new WP_User( $user_id );
        $user->set_role( 'subscriber' );
    
        // Email the user
        do_action( "adverts_new_user_notification", $user_id, null, "both", $password );
        
        return $user_id;
    }
    function adverts_add_username_field( $form ) {
        if( $form["name"] != "advert" ) {
            return $form;
        }
        $form["field"][] = array(            
            "name" => "my_username",
            "type" => "adverts_field_text",
            "order" => 2.1,
            "label" => "Username",
            "is_required" => false,
            "validator" => array()
        );    
        return $form;
    }
    
    Thread Starter inzerat

    (@inzerat)

    Hi thank you. You have true, better is email as username

Viewing 4 replies - 1 through 4 (of 4 total)
  • The topic ‘Normal username, not email username’ is closed to new replies.