duanfu3884 2016-05-24 09:38
浏览 19

从WordPress插件创建一个“隐藏”页面

I am developing a plugin where I need to send an activation link to subscribers.

Now I am stuck at the creation of the activation link. I want something like www.page.com/newsletter/activate?key=xxxx&hash=xxx.

But how to create this own slug without adding a content page? This page shouldn't have any output. After activation the script simply redirects to a confirmation page. This confirmation page shouldn't be a "real" content page too but should output a small text. How to do this from a plugin?

  • 写回答

2条回答 默认 最新

  • drlu11748 2016-05-24 10:04
    关注

    You can use the action of WordPress. In this case, you can handle the link like this:

    add_action('init', 'check_newsletter_link');
    function check_newsletter_link(){
        if (preg_match('/newsletter\/activate/', $_SERVER['REQUEST_URI']) && isset($_GET['key'], $_GET['hash'])){
            $key = $_GET['key'];
            $hash = $_GET['hash'];
            //Your code goes here
        }
    }
    

    You can write your PHP code there. WordPress action is a magic :)

    评论

报告相同问题?

悬赏问题

  • ¥20 机器学习能否像多层线性模型一样处理嵌套数据
  • ¥20 西门子S7-Graph,S7-300,梯形图
  • ¥50 用易语言http 访问不了网页
  • ¥50 safari浏览器fetch提交数据后数据丢失问题
  • ¥15 matlab不知道怎么改,求解答!!
  • ¥15 永磁直线电机的电流环pi调不出来
  • ¥15 用stata实现聚类的代码
  • ¥15 请问paddlehub能支持移动端开发吗?在Android studio上该如何部署?
  • ¥20 docker里部署springboot项目,访问不到扬声器
  • ¥15 netty整合springboot之后自动重连失效