Joomla Check If Front Page


This tutorial I will show you how to check if the user is viewing the front page of your Joomla website.

Joomla Create Plugin For Custom Component


In this tutorial I will show you how to create a custom plugin for your Joomla extension. This allows you to extend your component to other developers.

Joomla Redirect User With Code


This tutorial I will show you how to redirect users in your custom Joomla component. You can also send a message such as a success, warning, info.

Load Layout From Another View


There are many times in Joomla when you need to include a layout from another view, this could be a side bar or a view that contains items that should be on each pages.

Format Date In Joomla


In this tutorial I will teach you how to format the date. The date can be from an article, an extension or even the current date.

Joomla Check If Super Admin


In this tutorial, we will check that the logged in user has super admin rights, this work in Joomla 3 and above.

Joomla Add New User With Code


In this tutorial I will teach you how to add a new user to Joomla 3 and above using Joomla core classes.

Step 1.
Most cases you would retrieve the user details from a post such as the username, email and password. This tutorial I will manually add some demo user details..

$realname = 'Jake Test';
$username = 'jake';
$email    = '';
$password = 'password';     

Step 2.
Include Joomla 3 user helper file.


Step 3.
Build an array to store your user data. I used the variable named $udata to store the user details

			  $udata = array(

Step 4.
Other than the obvious, the thing to note here is the groups key in the array. I have it storing some default groups, which is guest and registered, you can also add additional group ids to the array if needed.

The final step is to get a new user object and bind the data array. This will use Joomla core classes to properly store the new user and we can retrieve the user id

     $user = new JUser;
        //Write to database
	if(!$user->bind($udata)) {
		throw new Exception("Could not bind data. Error: " . $user->getError());
	if (!$user->save()) {
		 throw new Exception("Could not save user. Error: " . $user->getError());
     $new_user_id = $user->id;

Now you can easily add a new user to your Joomla 3 and above with php codes. If you find this tutorial helpful and have any questions, please post a comment below.

Welcome to Western Studios

We provide professional website and mobile softwares including Joomla, Wordpress and more.