Title: Email login
Last modified: September 1, 2016

---

# Email login

 *  [anfieldleung](https://wordpress.org/support/users/anfieldleung/)
 * (@anfieldleung)
 * [10 years ago](https://wordpress.org/support/topic/email-login/)
 * Hi,
 * We are using email address as login id in our CAS, is it possible validate user
   against the email address on WordPress instead of the username after the authentication
   passed in CAS? If so, how to achieve this? Thanks
 * [https://wordpress.org/plugins/wp-cassify/](https://wordpress.org/plugins/wp-cassify/)

Viewing 8 replies - 1 through 8 (of 8 total)

 *  Plugin Author [Alain-Aymerick FRANCOIS](https://wordpress.org/support/users/aaf017/)
 * (@aaf017)
 * [10 years ago](https://wordpress.org/support/topic/email-login/#post-7551574)
 * Hi,
 * The plugin use the value inside cas:user tag in xml CAS Server response to validate
   user. So, if cas:user tag contains user email, it’s good.
 * Best regards.
 *  Thread Starter [anfieldleung](https://wordpress.org/support/users/anfieldleung/)
 * (@anfieldleung)
 * [10 years ago](https://wordpress.org/support/topic/email-login/#post-7551579)
 * Hi,
 * The value of cas:user tag will validate with WP email but not uesrname?
 *  Plugin Author [Alain-Aymerick FRANCOIS](https://wordpress.org/support/users/aaf017/)
 * (@aaf017)
 * [10 years ago](https://wordpress.org/support/topic/email-login/#post-7551598)
 * No, cas:user tag will validate with WP user_login value.(WordPress pre-existing
   accounts) If user already exist in WordPress before WP Cassify plugin activation,
   you van perform an SQL update query to update WP user_login with user_email.
   
   If WordPress user account does not yet exist, you can check option “create user
   if not exist”. Then WordPress user account will ne created with cas:user tag 
   value as user_login (So email in your case).
 *  Thread Starter [anfieldleung](https://wordpress.org/support/users/anfieldleung/)
 * (@anfieldleung)
 * [10 years ago](https://wordpress.org/support/topic/email-login/#post-7551599)
 * Thanks, that is what I understand.
    So my question is can I use the cas:user 
   tag to validate with WordPress user_email? If not, any impact if I update the
   user_login with user_email since it is restricted with lowercase character and
   number only in WordPress Multisite by default. There should be some reason behind
   that prohibited to do so?
 *  Plugin Author [Alain-Aymerick FRANCOIS](https://wordpress.org/support/users/aaf017/)
 * (@aaf017)
 * [10 years ago](https://wordpress.org/support/topic/email-login/#post-7551612)
 * I don’t know if it answer to you question but i try anyway.
 * I think it’seems to be possible with hack the plugin code.
    But it assume that
   you return email in cas:user tag.
 * You can try to replace function code like this (the function is located in classes/
   wp_cassify_utils.php) :
 *     ```
       public static function wp_cassify_auth_user_wordpress( $cas_user_id ) {
   
       		if ( email_exists( $cas_user_id ) ) {
       			$user = get_user_by( 'email', $cas_user_id );
   
       			wp_set_current_user( $user->ID, $user->user_login );
       			wp_set_auth_cookie( $user->ID );
   
       			do_action( 'wp_login', $user->user_login );
       		}
       		else {
       			die( 'User account does not exists in WordPress database !');
       		}
       	}
       ```
   
 * Best regards.
 *  Thread Starter [anfieldleung](https://wordpress.org/support/users/anfieldleung/)
 * (@anfieldleung)
 * [10 years ago](https://wordpress.org/support/topic/email-login/#post-7551700)
 * Thanks a lot! Will try with method you suggest.
 *  Thread Starter [anfieldleung](https://wordpress.org/support/users/anfieldleung/)
 * (@anfieldleung)
 * [9 years, 12 months ago](https://wordpress.org/support/topic/email-login/#post-7551799)
 * I tried with the suggested modification above and it works as expected. Thanks
   a lot.
    My last question is , how can I prevent the logic within this function
   will not be overridden if there are any update of the plugin in future?
 *  Thread Starter [anfieldleung](https://wordpress.org/support/users/anfieldleung/)
 * (@anfieldleung)
 * [9 years, 10 months ago](https://wordpress.org/support/topic/email-login/#post-7721096)
 * Hi Alain-Aymerick,
 * Is there any hook for wp_cassify_auth_user_wordpress function so that I can build
   my own function and replace with existing one? Or else, is there any way to keep
   my own modified wp_cassify_auth_user_wordpress function not being overridden 
   even there is update of WP Cassify?
    Sorry I am quite green on WP development.
   Thanks your support!

Viewing 8 replies - 1 through 8 (of 8 total)

The topic ‘Email login’ is closed to new replies.

 * ![](https://ps.w.org/wp-cassify/assets/icon-256x256.png?rev=3112582)
 * [WP Cassify](https://wordpress.org/plugins/wp-cassify/)
 * [Frequently Asked Questions](https://wordpress.org/plugins/wp-cassify/#faq)
 * [Support Threads](https://wordpress.org/support/plugin/wp-cassify/)
 * [Active Topics](https://wordpress.org/support/plugin/wp-cassify/active/)
 * [Unresolved Topics](https://wordpress.org/support/plugin/wp-cassify/unresolved/)
 * [Reviews](https://wordpress.org/support/plugin/wp-cassify/reviews/)

 * 8 replies
 * 2 participants
 * Last reply from: [anfieldleung](https://wordpress.org/support/users/anfieldleung/)
 * Last activity: [9 years, 10 months ago](https://wordpress.org/support/topic/email-login/#post-7721096)
 * Status: not resolved