Hi James,
You can use the following code in your functions.php file of the currently active theme:
add_filter( 'login_url', 'login_url_cb', 10, 2 );
function login_url_cb($login_url, $redirect){
$login_page_id = uwp_get_page_id('login_page', false);
$redirect_page_id = uwp_get_option('login_redirect_to', -1);
if ($login_page_id) {
$login_page = get_permalink($login_page_id);
if($redirect){
$login_url = add_query_arg( 'redirect_to', $redirect, $login_page );
}elseif(isset($redirect_page_id) && (int)$redirect_page_id == -1 && wp_get_referer()) {
$redirect_to = esc_url(wp_get_referer());
$login_url = add_query_arg( 'redirect_to', $redirect_to, $login_page );
}elseif($redirect_page_id){
$redirect_to = get_permalink($redirect_page_id);
$login_url = add_query_arg( 'redirect_to', $redirect_to, $login_page );
}else{
$login_url = $login_page;
}
}
return $login_url;
}
Let me know if it works for you or not.
Regards,
Patrik