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?
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 ); ?>
本回答被题主选为最佳回答 , 对您是否有帮助呢?解决 无用评论 打赏 举报