Hello! I am setting up OSSN for my business. All of my employees have an email address that ends in my domain name I wanted to know if there was a way to make it so only people with that address can make accounts?
Thank you for the help! I will try this tomorrow. I am used to working with java so I am not to good with PhP. If I can’t get it to work I’ll email you though!
Dear Adian, you need to consult the developer for that. It requires good knowledge in programming to handle the case. The developer need to check the
$email = input('email');
and then the rest condition need to be written.In the end it should appear like this
function restrict_usernames($name, $type, $params) {
if($params['action'] == 'user/register') {
$email = input('email');
if($email does not contain your domain then do not allow it) {
//if(!str_ends_with('@yourdomain.com', $email){
header('Content-Type: application/json');
echo json_encode(array(
'dataerr' => ossn_print('restrictusername:error'),
));
exit();
}
}
}
You may contact me at [email protected] for custom work at additional cost.
I now have `function restrict_usernames($name, $type, $params) {
if($params['action'] == 'user/register') {
$username = strtolower(input('username'));
$component = new OssnComponents();
$list = $component->getSettings('RestrictUsernames');
if($list && isset($list->list) && !empty($list->list)) {
$usernames = explode(PHP_EOL, $list->list);
$usernames = array_map('strtolower', $usernames);
$usernames = array_map('trim', $usernames);
$email = input('email');
header('Content-Type: application/json');
echo json_encode(array(
'dataerr' => ossn_print('restrictusername:error'),
));
exit();
}
}
}`
Will it only restrict the end of the email like @email.com?
Like this? if(in_array($email = input('email');)) {
You can see https://www.opensource-socialnetwork.org/component/view/5891/restrict-usernames and clone component it does same thing but you need to adjust https://github.com/opensource-socialnetwork/RestrictUsernames/blob/main/ossn_com.php#L31
$email = input('email');
Due to the many requests in the past for additonal features and components we have decided to develope a premium version. Features like Hashtags, Videos, Polls, Events, Stories, Link Preview, etc included in it.
$199 (Life Time)