I want to prevent users from registering on my site if they enter a username from a given list.
In my rule I've entered the event as "After saving a new user account" and the condition as "text comparison" with the data selector "account:name".
Problem 1) I can't seem to enter a list of usernames in the "matching text - value" box, only one name at a time (surely I don't have to create multiple "or" conditions for each name in my list?)
Problem 2) The "comparison operation value" doesn't give the option "equals" so if I use "contains" this would block a legitimate username which is a string containing a banned username.
Problem 3) In my "actions" I have "display a message" and this works if the text comparison is true, so it seems my event and action are correct in principle. But I can't block the user - I have another action element "Block a user" with the Parameter: "User: [account]" but the user remains active. (Ideally the user wouldn't be blocked but rather the account would not actually be registered, and the user trying to register would just be sent back to the "register account" form to enter a different username.)
Is this doable with Rules or do I need a custom module?
Comments
Comment #1
jigish.addweb CreditAttribution: jigish.addweb at AddWeb Solution Pvt. Ltd. commentedYou need to follow below steup.
1) You need to create your custom rule event with below code.
Event : Your custom rule event name
Actions : Set message for banned username
Page redirect(on particular location)
2) Apply hook on user registration form and write a code for check banned username. If username is in list of banned username then call your event within your code.
Let me know in case of any query/concern regarding this.
Thanks!
Comment #2
TR CreditAttribution: TR commented#1 will work. Or you can use a regular expression to do the text comparison, or you can write your own Rules condition to use, or you can populate a list data variable with all your words then do a text comparison against the list in a loop.
Writing your own hook as in #1 will be the simplest and most efficient way of checking against an arbitrarily large list from an arbitrary source. Invoking your own custom event will give you a simple and flexible way to react when you encounter a username you want to ban.
Comment #3
TR CreditAttribution: TR commented