Hi,
I am trying to create a basic plug-in for the use of a white list. So the opposite of the blacklist2
I am unable to get a hook working. Could some one please explain (in tutorial form) how I would be able to create a basic whitelist
Many thanks
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.
- Matt Beckett@Beck24
Matt Beckett - 0 likes
- dudeElgg@dudeElgg
dudeElgg - 0 likes
- Nikolai Shcherbin@rivervanrain
Nikolai Shcherbin - 0 likes
- dudeElgg@dudeElgg
dudeElgg - 0 likes
- ihayredinov@ihayredinov
ihayredinov - 0 likes
- iionly@iionly
iionly - 0 likes
You must log in to post replies.A whitelist for what?
Thank you Matt of your interest.
Without changing the core (the easiest way), I would like limit the username to a-z,0-9? And limit some username like admin, superuser, dot (.), etc.
For example:
if(preg_match("/^[a-zA-Z0-9]/", $username) == 1) {
// username only contain the a to z , A to Z, 0 to 9
}
How would create a simple plug-in with start.php (and manifest). It should be very straight forward but my hooks do not catch the username (I am sure i am doing something wrong). A tutorial template would be helpful :)
Just add these users via Administration -> Add new user
And then ban them ;)
Thanks but about username only contain the a to z , A to Z, 0 to 9 ???
http://learn.elgg.org/en/2.0/guides/hooks-list.html#user-hooks
Register a function to the 'registeruser:validate:username', 'all' plugin hook. Within the function check $params['username'] if the username contains characters (or whole specific usernames) you won't allow. Return true/false depending on the username is valid or not according to your requirements.
You can also take a look at the function validate_username() in vendor/elgg/elgg/engine/lib/users.php to see how Elgg validates a username