Hi everyone,
I'm working on the new version of my theme and by the way on a big website which is a serious project for me.
I wanted to add a feature to Elgg => Approve users who have only a mail adress who belong to a specific domain
I saw members of the community looking for such a code so here is the thing :
No plugin needed so it's very light code
Edit the file engine/lib/users.php
go straight to the line 921
between those two lines :
$email = trim($email);// A little sanity checking
$allowed = array('example.com', 'example2.com');
// Make sure the address is valid
if (filter_var($email, FILTER_VALIDATE_EMAIL))
{
$domain = array_pop(explode('@', $email));if ( ! in_array($domain, $allowed))
{
$email = 0;
}}
Now, your website will only registration for users who have a email adress like john.smith@example.com or john.smith@example2.com
Hope you liked it!
info@elgg.org
Security issues should be reported to security@elgg.org!
©2014 the Elgg Foundation
Elgg is a registered trademark of Thematic Networks.
Cover image by RaĆ¼l Utrera is used under Creative Commons license.
Icons by Flaticon and FontAwesome.
- iionly@iionly
iionly - 0 likes
- Staszek@stanl
Staszek - 0 likes
- rjcalifornia@rjcalifornia
rjcalifornia - 0 likes
- iionly@iionly
iionly - 0 likes
- Evan Winslow@ewinslow
Evan Winslow - 0 likes
- Staszek@stanl
Staszek - 0 likes
You must log in to post replies.In actions/register.php there the plugin hook 'register', 'user' triggered. It might be possible (better?) to use this plugin hook to check for the email domain. Then you could include the check in a separate plugin - even with the possibility to allow definition of allowed domains via site. You would not need to modify core files and would be safe to not lose your modifications after the next site update. When not including the option to define the email domain list on site the code of such a plugin wouldn't be more than a few lines either.
I make the fastest Elgg website I can : So instead of adding a plugin, which means a new start.php to execute and many files to load for just 1 feature, I prefer to modify the core directly
Result : my website is as fast as facebook
that's my philosophy ;-)
The website is nearly finished
I wouldn't recommend modifying core files. Listen to iionly, it will save you problems
If you want to create a website that's difficult to administrate and complicated to upgrade, please do.
But please don't post a general advice to modify core files when there's a simple way to achieve the same by coding it as a plugin. Many files? It's just start.php and manifest.xml. And it won't slow down your site either. Site speed mostly depends on a well configured server (and some minimum needed hardware requirements). Implementing features as plugins or not won't influence your site speed noticeable. Of course, when the code is bad or adds some heavy-weight features it will slow down your site - but it will do so regardless if you have modified the core files or included it in the standard way as a plugin.
https://github.com/elgg/emaildomains
Do NOT modify core.
Ok ok I surrender! Don't shoot!