Osclass Support Forums
Osclass plugin support => Other => Topic started by: oscman on December 23, 2019, 12:32:42 PM
-
Hello, i have this function so people can register only with gmail and hotmail, when i try to register it works gr8 but i still see spambots registering under different email domains and bypass this code, any idea how they do it?
function cust_restrict_mail_providers() {
$authorized_providers = array(
'gmail.com',
'hotmail.com'
);
$current_provider = preg_replace('/^.*@(.*)$/i', '$1', Params::getParam('s_email'));
if (!in_array($current_provider, $authorized_providers)) {
osc_add_flash_error_message( _m('Your current email is not allowed'));
osc_redirect_to(osc_register_account_url());
}
}
osc_add_hook('before_user_register', 'cust_restrict_mail_providers');
-
Code looks OK, but try to put:
exit;
after line:
osc_redirect_to(osc_register_account_url());
-
Thanks will see if it makes change
-
Hello There ,
I also want to restrict users for registration, where i have to paste this code (in which file ).. I want to allow only some popular email server like gmail.com, live.com and more.. Because too many fake registration in my website.
I have tried to put this code in user registration php file but not working . Please help me to solve the issue.
<?php
function cust_restrict_mail_providers() {
$authorized_providers = array(
'hotmail.com',
'mail.live.com',
'live.com',
'gmail.com'
);
$current_provider = preg_replace('/^.*@(.*)$/i', '$1', Params::getParam('s_email'));
if (in_array($current_provider, $authorized_providers)) {
osc_add_flash_error_message( _m('Accounts not allowed'));
osc_redirect_to(osc_register_account_url());
exit;
}
}
osc_add_hook('before_user_register', 'cust_restrict_mail_providers');
?>
Thanks
-
Please reply
Code looks OK, but try to put:
exit;
after line:
osc_redirect_to(osc_register_account_url());
-
You can place it into functions.php of theme
-
Thanks for Reply.
I have pasted this code into functions.php but still I am able to register fake account. [email protected]
<?php
function cust_restrict_mail_providers() {
$authorized_providers = array(
'hotmail.com',
'mail.live.com',
'live.com',
'gmail.com'
);
$current_provider = preg_replace('/^.*@(.*)$/i', '$1', Params::getParam('s_email'));
if (in_array($current_provider, $authorized_providers)) {
osc_add_flash_error_message( _m('Accounts not allowed'));
osc_redirect_to(osc_register_account_url());
exit;
}
}
osc_add_hook('before_user_register', 'cust_restrict_mail_providers');
?>
You can place it into functions.php of theme
-
I would double check if email field on register page has nane s_email and then I think condition should be !in_array(...
-
Thanks for your Reply. Now its working. :) :)
I would double check if email field on register page has nane s_email and then I think condition should be !in_array(...
-
I would just summarize final code.
// restrict particular email domains
function cust_restrict_mail_providers1() {
$authorized_providers = array(
'hotmail.com',
'mail.live.com',
'live.com',
'gmail.com'
);
$current_provider = preg_replace('/^.*@(.*)$/i', '$1', Params::getParam('s_email'));
if (in_array($current_provider, $authorized_providers)) {
osc_add_flash_error_message(_m('Email domain is blocked'));
osc_redirect_to(osc_register_account_url());
exit;
}
}
osc_add_hook('before_user_register', 'cust_restrict_mail_providers1');
// only allow particular email domains
function cust_restrict_mail_providers2() {
$authorized_providers = array(
'hotmail.com',
'mail.live.com',
'live.com',
'gmail.com'
);
$current_provider = preg_replace('/^.*@(.*)$/i', '$1', Params::getParam('s_email'));
if (!in_array($current_provider, $authorized_providers)) {
osc_add_flash_error_message(_m('Email domain is not allowed'));
osc_redirect_to(osc_register_account_url());
exit;
}
}
osc_add_hook('before_user_register', 'cust_restrict_mail_providers2');
-
Thanks for reply.. but its already working