views:

26

answers:

2

I have a Wordpress site and what I would like to do is for users to send their email address through a form and then my email client would send automatically message them with a link to a certain page. That page should not be accessable without that link. Is that possible to do and are there any ready plugins for this? I use a members plugin, but I want users only to give their email and not to fill out a whole form. Hope you understand. Thanks. w

A: 

So no one can help me? :/

givey
A: 

The better route is to just use the built-in sign-up system. Is there some reason that didn't work for you?

Short of that, here is a quick and dirty approach...

To send mail to a user, just put the following PHP code in a page:

mail($_GET['user_email_address'], 'Access to site', 'To access the site please use ' . get_bloginfo('url') . '/foo.php?access=1');

The first parameter assumes the page that calls this has an textbox with the name 'user_email_address'. The subject and content of the mail follow; you can change them to reflect what you reallyw ant.

Then on the page you want to restrict access to, put the following code at the top of the file:

if (!isset($_GET['access']))
     wp_redirect(get_option('siteurl') . '/wp-login.php?action=register');

This redirects anyone who doesn't have the get parameter access. This system has two main shortcomings:

  • you can easily copy/paste and share this URL and anyone will be able to bypass the e-mail
  • if you try to return to the page later you won't be able to get to it without the get parameter

If you provide more details on why the built-in registration system didn't work, I might be able to help better.

-Kevin

KevinM