I have one WordPress installation . i need to log out the user without any indication user is coming from particular URL.Is it possible?
My code:
<?php
if($_GET['logout'] == 1)
{
$redirect_to = current_page_url();
?>
<script>
window.location.href="<?php echo wp_logout_url( $redirect_to ); ?>";
</script>
<?php
}
?>
I am using above code in my header.php . When the user click particular link with log out parameter value is 1. I need to log out the user without any log out confirmation.
I tried with the above code but its asking the following Confirmation.is it possible to avoid this confirmation.
"You are attempting to log out of Learn
Do you really want to log out?"
My requesting URL is like this
http://localhost/learnwordpresslogout=1&redirect='/learnwordpress/category/category1'
I need to log out the user without confirmation and redirect to redirect parameter value URL.Is it possible?
Try wp_logout() function
use the funtion .
Get More Details for
wp_logout_url()
https://codex.wordpress.org/Function_Reference/wp_logout_urlGet More Details for
get_permalink();
https://codex.wordpress.org/Function_Reference/get_permalink