Logout Feature Code Snippet
-
Hi,
My site has a login feature for customers if they want to login. The problem I have is currently when a customer logs in there is not option and/or button to log out.I have added the below code to the Snippets plugin but the logout feature is not working.
Could you please help me with this and let me know where I am going wrong?
/**
* Add a WooCommerce logout page shortcode button
*/// Shortcode Action hook
add_shortcode( ‘wc_logout_shortcode’, ‘njengah_wc_logout_shortcode’ );
// Callback
function njengah_wc_logout_shortcode(){
ob_start();
// Check if user is logged in
if (is_user_logged_in()){
// Create the url variable
$wc_shortcode_logout_url = site_url() . ‘/?customer-logout=true’;?>
<button class=”wc_logout_shortcode_btn”>“>Log Out</button>
<?php
}return ob_get_clean();
}The page I need help with: [log in to see the link]
The topic ‘Logout Feature Code Snippet’ is closed to new replies.