mardi 19 janvier 2016

Create An Optin Form Shortcode That Creates a New User Automatically?

My website runs on WordPress and I am good with it. I have several pages and articles that include a shortcode for a MailChimp Optin form, it asks for First Name and Email.

What I want is, instead of these guys to be signed up to MailChimp, create an user account automatically on my website. I am then going to sync these new accounts with MailChimp.

I would rather code the shortcode/plugin myself as I am doing well so far doing it all with my own coding.

The form is simple, it asks for Full Name and Email.

I then need to...

  1. Check if email exists or not in the DB, if not then we can carry on
  2. Parse the full name and turn it into a wordpress-friendly username
  3. Create a new WP user using wp_create_user (generate random pwd)
  4. Email the user to confirm optin/user account with password details and link to whatever they signed up/opted in for (bonuses pages for instance)

I am confused to where should I send that FORM/POST request to? Should I create a page with its own .php template and I can then process the request there or should I use a hook instead to test for $POST['myform_email']?

Just need to have your opinion on how to do it so it is clean and efficient.



via Chebli Mohamed

Aucun commentaire:

Enregistrer un commentaire