• I am looking for a php code which automatically creates a username for EACH visitor that views my site.

    After creating the user it should auto login.

    Username can be created from date, time, ip, or whatever

    Is there a simple way to do this, which enables me to autoregister visitors and allowing them to add email address if they find the site interesting?

Viewing 2 replies - 1 through 2 (of 2 total)
  • Moderator bcworkz

    (@bcworkz)

    You would basically use register_new_user() followed by wp_signon()

    You can create sequentially numbered user names, user1, user2, etc. Keep track of the last assigned number by storing it in the options table with add_option()

    You will have to assign some kind of email to register a new user, there’s no way around it. It just needs to be a valid form, it doesn’t have to work. You could build a dummy email using your own domain, as in user123@{$your_domain}.com The user can change it to a valid one anytime they like.

    That said, I don’t think this is a good idea. Your DB will fill up with users that will never come back. Once the user’s auth cookie expires, if they do not login with their assigned credentials, they will be added as another new user. Thus your DB will also fill up with many users created for the same single visitor.

    Any search bot visiting your site will also be made into a user, as will bad actors trying to hack your site. Sorry, I’m just not seeing this as a viable scheme.

    Why not let visitors browse your site without making them users? If they like what they see, they can register as usual. This registration is not much more involved than changing the auto-assigned email, plus it serves to confirm that the email is functional. This doesn’t happen when the email is simply edited.

    I see this as being much more information to store than I think you would end up wanting to. I use computers in like at least 10-15 different locations at some times. This would mean I would possibly have at least 10-15 different accounts on your website? I agree with bcworkz and think you may want to give your users the option to become a registered user.

Viewing 2 replies - 1 through 2 (of 2 total)
  • The topic ‘Create user for each visitor automatically’ is closed to new replies.