Wordpress log out using URL and redirect to specify page

admin

Administrator
Staff member
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:

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.

Code:
"You are attempting to log out of Learn

Do you really want to log out?"

My requesting URL is like this

Code:
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?