I am making an attempt to redirect customers once they go to my web page template template-logout.php
, however I preserve getting the WordPress “Do you actually wish to logout?” query regardless of wpnonce being generated. What am I doing flawed?
Here is an instance of the kind of URL being generated by my perform beneath after I attain that WP affirmation web page:
https://localssl:8890/wp-login.php?motion=logout&redirect_to=httpspercent3Apercent2Fpercent2Flocalsslpercent3A8890&_wpnonce=752dc07192
CODE
template-logout.php
<?php
/**
* Template title: Log Out
*/
get_header();
// Logic dealt with through features.php
get_footer(); ?>
features.php
// Redirects for template pages
add_filter('template_redirect', 'osu_redirect_on_logout');
perform osu_redirect_on_logout() {
if ( is_page_template( 'templates/template-logout.php' ) ) {
$logout_url = wp_logout_url( home_url() );
wp_safe_redirect( $logout_url ); // Logout and Redirect to homepage
exit;
}
}