michaelryanmcneill / shibboleth

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

Replace update_usermeta() with update_user_meta() #2

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 update_usermeta() with update_user_meta(): https://github.com/michaelryanmcneill/shibboleth/blob/master/shibboleth.php#L363

// update user data
update_usermeta($user->ID, 'shibboleth_account', true);
shibboleth_update_user_data($user->ID);
if ( shibboleth_get_option('shibboleth_update_roles') ) {
    $user->set_role($user_role);
    do_action( 'shibboleth_set_user_roles', $user );
}
return $user;
/**
 * Create a new WordPress user account, and mark it as a Shibboleth account.
 *
 * @param string $user_login login name for the new user
 * @return object WP_User object for newly created user
 */
function shibboleth_create_new_user($user_login) {
    if ( empty($user_login) ) return null;
    // create account and flag as a shibboleth acount
    require_once( ABSPATH . WPINC . '/registration.php' );
    $user_id = wp_insert_user(array('user_login'=>$user_login));
    $user = new WP_User($user_id);
    update_usermeta($user->ID, 'shibboleth_account', true);
    // always update user data and role on account creation
    shibboleth_update_user_data($user->ID, true);
    $user_role = shibboleth_get_user_role();
    $user->set_role($user_role);
    do_action( 'shibboleth_set_user_roles', $user );
    return $user;
}

See more: https://developer.wordpress.org/reference/functions/update_usermeta/ https://developer.wordpress.org/reference/functions/update_user_meta/