So I have just setup tank auth, I have not changed anything yet so everything should be default. It works perfectly fine. However I want to require for a certain domain for emails to be able to login. For now I will say gmail. So how can i make it so it checks that the email address has @gmail.com in it before the user can register. I have found where the valid email error message is and can change that but i cannot find where the actual check for the valid email.
1条回答 默认 最新
- douqie3391 2012-08-30 22:44关注
Tank auth is using CI's default
valid_email
validation rule, found in the Form Validation class.It's definitely a strange thing to want to do, but you can create a callback validation function and add it to your form validation rules on the registration page.
This is basically the equivalent of an
ends_with
rule, but adds the "@":// Check if the inputs last characters matches the parameter function is_email_domain($input, $domain) { $domain_str = '@'.$domain; $result = strpos($input, $domain_str) === (strlen($input) - strlen($domain_str)); if ( ! $result) $this->form_validation->set_message('is_email_domain', 'The %s field must be a %s email address'); return $result; }
So create the callback function in your controller and add it to the validation:
$this->form_validation->set_rules( 'email', 'Email', 'trim|required|xss_clean|valid_email|callback_is_email_domain[gmail.com]' );
本回答被题主选为最佳回答 , 对您是否有帮助呢?解决 无用评论 打赏 举报
悬赏问题
- ¥15 写uniapp时遇到的问题
- ¥15 matlab有限元法求解梁带有若干弹簧质量系统的固有频率
- ¥15 找一个网络防御专家,外包的
- ¥100 能不能让两张不同的图片md5值一样,(有尝)
- ¥15 informer代码训练自己的数据集,改参数怎么改
- ¥15 请看一下,学校实验要求,我需要具体代码
- ¥50 pc微信3.6.0.18不能登陆 有偿解决问题
- ¥20 MATLAB绘制两隐函数曲面的交线
- ¥15 求TYPCE母转母转接头24PIN线路板图
- ¥100 国外网络搭建,有偿交流