michaelryanmcneill / shibboleth

Shibboleth plugin for WordPress
https://wordpress.org/plugins/shibboleth/
19 stars 11 forks source link

Replace get_userdatabylogin() with get_user_by() #1

Closed michaelryanmcneill closed 6 years ago

michaelryanmcneill commented 6 years ago

Note: This issue was replicated from the original fork of the Shibboleth plugin located here: https://github.com/michaelryanmcneill/shibboleth-fork.

Replace get_userdatabylogin() with get_user_by(): https://github.com/michaelryanmcneill/shibboleth/blob/master/shibboleth.php#L229

/**
 * If a Shibboleth user requests a password reset, and the Shibboleth password
 * reset URL is set, redirect the user there.
 */
function shibboleth_retrieve_password( $user_login ) {
    $password_reset_url = shibboleth_get_option('shibboleth_password_reset_url');
    if ( !empty($password_reset_url) ) {
        $user = get_userdatabylogin($user_login);
        if ( $user && get_user_meta($user->ID, 'shibboleth_account') ) {
            wp_redirect($password_reset_url);
            exit;
        }
    }
}
add_action('retrieve_password', 'shibboleth_retrieve_password');

See more: https://developer.wordpress.org/reference/functions/get_userdatabylogin/ https://developer.wordpress.org/reference/functions/get_user_by/