- shares
- Facebook Messenger
- Gmail
- Viber
- Skype
– Thông thường wordpress đăng nhập bằng username, đôi khi bạn muốn người dùng của bạn đăng nhập bằng email. Bằng cách loại bỏ cách authenticate thông thường và thêm luật filter authenticate mới, xác thực user_login bởi email người đăng nhập cung cấp. Xem code dưới đây.
// remove the default filter remove_filter('authenticate', 'wp_authenticate_username_password', 20, 3); //custom authenticate, vd: đăng nhập user bởi email add_filter('authenticate', 'fb_authenticate_username_password', 20, 3); function fb_authenticate_username_password($user, $username, $password) { // If an email address is entered in the username box, // then look up the matching username and authenticate as per normal, using that. if (!empty($username)) $user=get_user_by('email', $username); //lấy user if (isset($user->user_login, $user)) $username=$user->user_login; //print_r($user); // using the username found when looking up via email return wp_authenticate_username_password(NULL, $username, $password); }
Nếu bạn thích bài viết này, hãy ủng hộ chúng tôi bằng cách đăng ký nhận bài viết mới ở bên dưới và đừng quên chia sẻ kiến thức này với bạn bè của bạn nhé. Bạn cũng có thể theo dõi blog này trên Twitter và Facebook
- shares
- Facebook Messenger
- Gmail
- Viber
- Skype
Hi ad Sau khi cài đặt với 1 gmail, khi vào lại setting của WP Mail SMTP thì dòng From Email mặc định với email cũ, giờ mình muốn thay đổi sang email theo tên miền riêng thì mình thay đổi chỗ nào ? Cám ơn !
Mình làm theo hướng dẫn cấu hình Mail SMTP nhưng không gởi mai dc và báo lỗi : 401. That’s an error.