You can try this code snippet.
add_filter( 'wp_redirect', 'um_logout_redirect_url_encode', 10, 2 );
function um_logout_redirect_url_encode( $url, $status ) {
if ( strpos( $url, 'login' )) {
$url = urlencode( $url );
}
return $url;
}Install by adding the code snippet to your active theme’s functions.php file
or use the “Code Snippets” Plugin
Thread Starter
sao987
(@sao987)
Thank you very much for your snippet. However, it doesn’t seem to change the logout link in login form at all. It doesn’t seem wp_redirect filter applies here. Not so sure how the login form functions.
This logout redirect url is in the login form, when the user visit the login url while logged in.
Thread Starter
sao987
(@sao987)
Thanks again for the help, I had a search and found the function to build this page, and come up with a snippet based on your idea.
I will leave it here just in case anyone need it.
function custom_um_logout_user_links( $args ) {
// Encode the current URL and build the logout URL with the encoded redirect_to
$logout_url = add_query_arg( 'redirect_to', rawurlencode( UM()->permalinks()->get_current_url( true ) ), um_get_core_page( 'logout' ) );
?>
<?php
}
// Remove the existing action
remove_action( 'um_logout_user_links', 'um_logout_user_links', 100 );
// Add the custom action
add_action( 'um_logout_user_links', 'custom_um_logout_user_links', 100 );
