wp_logout_url() not redirecting the user

Question

I am writing a plugin that will redirect the user after logout. If the user provides a link then redirect the user to that place else use the default URL.
Here is the code I use.

echo esc_url(wp_logout_url( ud_logout_redirect() ));

Here is the ud_logout_redirect() function.

function ud_logout_redirect() {
        $redirect_link = 'https://example.com';
        $logoutOption = isset( ud_redirection_options()['logout_link_redirect'] ) ? ud_redirection_options()['logout_link_redirect'] : null;
        if (  ! $logoutOption == null ) {
            $redirect_link = apply_filters( 'filter_ud_logout_redirect', $logoutOption);
        }

        return $redirect_link;
    }

If the user doesn’t provide a link the example.com will be default but the wp_logout_url() doesn’t redirect the user. But it redirects the user to wp-login.php

Thanks in advance

0
Raashid Din 8 months 2020-12-05T06:10:21-05:00 0 Answers 12 views 0

Leave an answer

Browse
Browse