We are currently using Joomla's user class to create new staff, In our staff page. It works well and successfully creates the new user account. But we have an issue. Because the user account button at the top of screen also relies on calls to a Joomla user object, once we create a new user, the moment after creation the name displayed is that of the user we just created. Now once you refresh or move to another page the issue disappears.

If we wish to avoid the confusion this instance might cause, it might make sense to move the method we use to create new users out of the page and into a separate file; correct? Or would it not be worth it, given that it has no other effects but a temporary name that is resolved without any real effort on the part of the user?

This is the code we use:

$udata = array(
    "name"=>$_POST['firstName'].' '.$_POST['surName'],

$user = new JUser;
//Write to database
if(!$user->bind($udata)) {
    echo "<script>alert('Could not bind data. Error: ".$user->getError()."</script>";
if (!$user->save()) {
    echo "<script>alert('Could not save user. Error: " . $user->getError()."</script>";
} else { 
    echo "<script>alert('New User $user->id Created');</script>";
    // Script Here to enter additional details in usg_usg_staff table

Or would it be wiser to remove the user->name call?

  • Could you post your code and where you stuck it? Commented Dec 23, 2017 at 0:55
  • Sure,like I said it's in the usg-staff.php page
    – user11029
    Commented Jan 2, 2018 at 13:32

1 Answer 1


I finally resolved the issue. All I had to do was make sure that once the new user was created I set the $user variable back to the active user data by using JFactory::getUser(). I was really over thinking it. It was only displaying the just created user because after creating the user in our joomla table I had not thought to set it back.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

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