By default, Joomla will insure that a username and email is not already in use. I need to extend that to insure that the user provides a first name and last name (and is unique).

What is the best way to do this...I've explored using onUserBeforeSave in a user plugin, but this strikes me to be too late in the process.

  • Are you sure you want to have unique names? This should be a very specific case, otherwise I can't think why first/last name must be unique and how this could be useful.
    – FFrewin
    Nov 10 '14 at 19:32
  • It is a very specific case....its a small collection of Television producers, and uniqueness is part of the game...even without that, the first AND last requirement remains. Failing a user plugin test "works", but need to figure out how to set the error text that follows: "Save failed with the following error".
    – GDP
    Nov 10 '14 at 19:35
  • Also you may edit your #__users table structure in phpMyAdmin and change the "Index Type" of idx_name to UNIQUE.
    – Farahmand
    Nov 10 '14 at 21:18
  • Have to avoid hacks, and this rule only applies to a particular usergroup anyways, but thx
    – GDP
    Nov 10 '14 at 21:21
  • Yes, it's a DB hack but I think it applies to all users.
    – Farahmand
    Nov 10 '14 at 21:23

Well, this solution doesn't sit well with me, but it does work using the user plugin:

public function onUserBeforeSave($oldUser, $isnew, $newUser) {
    if($test == 'fails') {
        $error = ' First and Last Name must be specified';
        throw new Exception($error);
  • Just a note - if you throw an Exception return will never be reached. Nov 11 '14 at 13:58
  • A true...remnant development code - thx
    – GDP
    Nov 11 '14 at 14:14

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.