通过电子邮件链接访问 WordPress 页面

发布于 2024-09-03 14:09:16 字数 165 浏览 6 评论 0原文

我有一个 Wordpress 网站,我想做的是让用户通过表单发送他们的电子邮件地址,然后我的电子邮件客户端会自动向他们发送带有特定页面链接的消息。如果没有该链接,则不应访问该页面。这可以做到吗?有没有现成的插件可以做到这一点?我使用会员插件,但我希望用户只提供他们的电子邮件而不是填写整个表格。希望你理解。谢谢。 w

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

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(1

洒一地阳光 2024-09-10 14:09:16

更好的途径是仅使用内置的注册系统。有什么原因对你不起作用吗?

除此之外,这里有一个快速而肮脏的方法...

要向用户发送邮件,只需将以下 PHP 代码放入页面中:

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

第一个参数假设调用此代码的页面有一个名为“user_email_address”的文本框。邮件的主题和内容如下;您可以更改它们以反映您真正想要的内容。

然后,在要限制访问的页面上,将以下代码放在文件顶部:

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

这将重定向没有 get 参数访问权限的任何人。该系统有两个主要缺点:

  • 您可以轻松地复制/粘贴并共享此 URL,并且如果您稍后尝试返回该页面,任何人都将能够绕过电子邮件,
  • 如果没有 get,您将无法访问该页面参数

如果您提供有关内置注册系统为何不起作用的更多详细信息,我也许可以提供更好的帮助。

-凯文

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

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文