Christophe Barbier

Forum Replies Created

Viewing 1 post (of 1 total)
in reply to: wp_logout_url() redirect param broken #162685

Christophe Barbier
Participant

Hello,

I am running into the same issue. It looks like the source code is now located in (PRO version):
download-manager\src\User\Login.php
Line 44:
add_filter(“logout_url”, [$this, ‘logoutURL’], 999999, 2);

This filter has the highest priority, which will override other plugins. In our case, we are using “OpenID Connect Generic Client”:

OpenID Connect Generic Client

When calling this PHP function to get the “log out” URL:
wp_logout_url(get_permalink())

WPDM changes URL which look like this:
/wp-login.php?action=logout&redirect_to=
to
?logout?…

Because of that, as Nicholas said, the “action” parameter is ignored by WordPress, which never even gets in wp-login.php to apply other logic (such as the “logout_redirect” filter). In our case, when WPDM is activated, the log out function of our website doesn’t work anymore !
Worst thing is, we don’t even use the WPDM login function, and we still get that issue.

There is probably a better way to disable it (apart from changing the source code of WPDM), but we added this custom to our child theme :


# fix issue with WPDM adding custom logout filter
# see https://www.wpdownloadmanager.com/support/topic/wp_logout_url-redirect-param-broken/
function remove_filters_with_method_name( $hook_name = '', $method_name = '', $priority = 0 ) {
    global $wp_filter;
    // Take only filters on right hook name and priority
    if ( ! isset( $wp_filter[ $hook_name ][ $priority ] ) || ! is_array( $wp_filter[ $hook_name ][ $priority ] ) ) {
        return false;
    }
    // Loop on filters registered
    foreach ( (array) $wp_filter[ $hook_name ][ $priority ] as $unique_id ► $filter_array ) {
        // Test if filter is an array ! (always for class/method)
        if ( isset( $filter_array['function'] ) && is_array( $filter_array['function'] ) ) {
            // Test if object is a class and method is equal to param !
            if ( is_object( $filter_array['function'][0] ) && get_class( $filter_array['function'][0] ) && $filter_array['function'][1] == $method_name ) {
                // Test for WordPress >= 4.7 WP_Hook class (https://make.wordpress.org/core/2016/09/08/wp_hook-next-generation-actions-and-filters/)
                if ( is_a( $wp_filter[ $hook_name ], 'WP_Hook' ) ) {
                    unset( $wp_filter[ $hook_name ]->callbacks[ $priority ][ $unique_id ] );
                } else {
                    unset( $wp_filter[ $hook_name ][ $priority ][ $unique_id ] );
                }
            }
        }
    }
    return false;
}
remove_filters_with_method_name( 'logout_url', 'logoutURL', 999999 );

The code is from :
https://wordpress.stackexchange.com/a/304861/167013

This successfully removed the WPDM logout filter

Please fix this issue in WPDM directly, as it will produce unexpected results with many other WP extensions.

Thanks,

Viewing 1 post (of 1 total)