Search code examples
databasewordpressinvitation

Invitation code and users database in Wordpress


I need your precious help. I'm working hard on organizing a contest linked to a wordpress site. That's the way it should work:

  1. There's a contest. The user have to register as new user in WP (there's also the Facebook Connect/Open Graph) to enter the contest.
  2. When a new user register himself, the system sends him an email: "Congratulations! You are a new user. Here there are some invitation codes (or links) to invite your friends. If they register here with the invitation code (or link), you'll receive a gift".

How can i do this workflow? I need to generate some codes (or links) every time a new user enter the WP site and assign them (linking those data to the users). I need to know if a new user (called B) comes to my site thanks to another user (called A), in order to give to A a gift.

Thank you guys.


Solution

  • You must make a frontend registration. Then, after user is registered you send him an email like www.yourdomain.com/register?uid=his_id(link to te registration form with his id as a parameter).

    The when he passes the link to his friend B, friend B is registering and you check if there's a $_GET['uid']. It yes you add him a meta containing the id.

    1. To make a front-end registeration, you should check this article.

    2. For mail sending you could use wp_mail() function.

    3. For passing params in the url and accessing you must be familiar with $_GET

    4. For adding a meta for an user you must use the add_user_meta(). function.

    The above steps are not necessarily difficult if you know basic PHP and willing to learn from Wordpress codex.