在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?

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
        );

?>