I have a custom login form that takes the code from wp-login.php.
I can't use wp-login.php because when this file is used I refer them to my main login file, ie login.php.
Is there therefore a link or function that I can use to log out via the login.php page and not wp-login.php?
I also tried to use the following code but without success:
Thanks to those who will help me.
UPDATE:
I also tried to modify the following function and then apply it to a menu item but it still doesn't work.
function wp_new_logout_url( $redirect = '' ) {
$args = array( 'action' => 'logout' );
if ( ! empty( $redirect ) ) {
$args['redirect_to'] = urlencode( $redirect );
}
$logout_url = add_query_arg( $args, site_url( 'login.php', 'login' ) );
$logout_url = wp_nonce_url( $logout_url, 'log-out' );
return apply_filters( 'logout_url', $logout_url, $redirect );
}
This is where it is applied:
<a href="<?php echo wp_new_logout_url(); ?>">Logout</a>