duananyu9231
2018-07-19 18:14
浏览 37
已采纳

在php wordpress中创建取消订阅按钮

I want to add an unsubscribe button to the “account details” in woocommerce that will go into user_meta and change that user’s meta_key of newsletter from true to false (it is automatically set to true right now when registering). What steps should I take to do so?

图片转代码服务由CSDN问答提供 功能建议

我想在woocommerce的“帐户详细信息”中添加取消订阅按钮,该按钮将进入user_meta并更改该用户的 时事通讯的meta_key从true到false(注册时自动设置为true)。 我应该采取什么措施呢?

  • 写回答
  • 好问题 提建议
  • 关注问题
  • 收藏
  • 邀请回答

1条回答 默认 最新

  • douyicao2199 2018-07-19 20:10
    已采纳

    Have an anchor tag leading to the page you want user to goto after clicking unsubscribe, and toss a query parameter in the URL like so:

    <a href="/new-page?email=<user email>">Unsubscribe</a>
    

    Now on that page have the following before page content loads wrapped in php of course.

    <?php
        //TOSS USERS EMAIL INTO VARIABLE
        $user_email = $_GET['email'];
        global $wpdb;
        $wpdb->update( 
                $wpdb->base_prefix.'user_meta', 
                array( 
                    'newsletter' => 'false'
                ),
                $user_email
            );
    
    ?>
    
    已采纳该答案
    评论
    解决 无用
    打赏 举报

相关推荐 更多相似问题