diff --git a/024-How-to-integrate-the-Create-User-Helper-Method-in-your-Components.md b/024-How-to-integrate-the-Create-User-Helper-Method-in-your-Components.md index cadec5f..77b3457 100644 --- a/024-How-to-integrate-the-Create-User-Helper-Method-in-your-Components.md +++ b/024-How-to-integrate-the-Create-User-Helper-Method-in-your-Components.md @@ -1 +1,18 @@ -Hi I would like to give you a quick tutorial or demonstration on how to use user creation method or function In your component What is the user Creation function [00:00:18](https://www.youtube.com/watch?v=ckFakaQ90JY&list=PLQRGFI8XZ_wtGvPQZWBfDzzlERLQgpMRE&t=00h00m18s) It is basically a part of code's helper function actually That gets added to the helper class If you don't know where the helper class is let me quickly show you now if you go to your repository where you Find basically your Joomla install you would go to administrator Now there is a helper class for the front end of every component as well as for the back end so looking in a backend We go to component [00:00:55](https://www.youtube.com/watch?v=ckFakaQ90JY&list=PLQRGFI8XZ_wtGvPQZWBfDzzlERLQgpMRE&t=00h00m55s) Expert Database Helpers And it's basically that file there that is the helper Class if we open it we See that it's the abstract expert database helper Now that helper class gets included Into your component on every page so if you to open the main backend file with that one Which get loaded by Joomla first you'll see that it actually includes that helper file in every page [00:01:28](https://www.youtube.com/watch?v=ckFakaQ90JY&list=PLQRGFI8XZ_wtGvPQZWBfDzzlERLQgpMRE&t=00h01m28s) So that means everything inside of that Class is available to you everywhere in your component When we actually go back to our Interface And we go to components and the Expert Database You would see that there is a libs or actually stand for library and helpers and you see We have to switch Ticked yes add create user helper method Set to yes That is the [00:02:11](https://www.youtube.com/watch?v=ckFakaQ90JY&list=PLQRGFI8XZ_wtGvPQZWBfDzzlERLQgpMRE&t=00h02m11s) The switch that you need to trip So that component builder and knows that you actually want the helper class that Creates users to be Added to the helper class of your front and backend of your component I'm gonna close out here I am going to go back to the code And then I am going to do a Simple search for user [00:02:44](https://www.youtube.com/watch?v=ckFakaQ90JY&list=PLQRGFI8XZ_wtGvPQZWBfDzzlERLQgpMRE&t=00h02m44s) . Here is quite a few users there it is Create user As you can see this is a public static function So you would basically call it with that class name Then colon colon and the name of the function, right which is create user And you see that it is set to new [00:03:26](https://www.youtube.com/watch?v=ckFakaQ90JY&list=PLQRGFI8XZ_wtGvPQZWBfDzzlERLQgpMRE&t=00h03m26s) Now New has in it A few variables is basically an array So you can go through this class and you'd see that it has a password one or is just password or password two, it has a user name it has a name aswell as a e-mail And it then creates the user That's what this class does so it calls in the Joomla Component users [00:04:00](https://www.youtube.com/watch?v=ckFakaQ90JY&list=PLQRGFI8XZ_wtGvPQZWBfDzzlERLQgpMRE&t=00h04m00s) It calles in it's registration model And then it basically uses that model to create a user so that's what that switch does it adds this class to your component you can then use it in your component it doesn't automatically just sets everything else in place you still required to do as a developer to add to correct code I'll show you what I have done and how I am using it There is a admin View called experts it's in this view that I would actually like Option for someone to create a user now let me first demonstrate how it works So I would go to expert data base and click on experts Let's click on new So you would see there is a [00:04:55](https://www.youtube.com/watch?v=ckFakaQ90JY&list=PLQRGFI8XZ_wtGvPQZWBfDzzlERLQgpMRE&t=00h04m55s) field called Expert With which you can select Users within a specific group I will also explain some of that more later But underneath there is this button create user If you Click on it it basically has a pop-up where in you enter a user name I am just gonna say Testing 123 Use that as the username [00:05:26](https://www.youtube.com/watch?v=ckFakaQ90JY&list=PLQRGFI8XZ_wtGvPQZWBfDzzlERLQgpMRE&t=00h05m26s) And as the password There we go, got the user name So everything is testing 123 And if I click create it basically has this nice effect where it is busy creating it Setting it up, sending out the email doing all of that for you And once it's done It lets you know that user was created successfully and the login details was e-mailed to the user And then it says here ready to select [00:06:05](https://www.youtube.com/watch?v=ckFakaQ90JY&list=PLQRGFI8XZ_wtGvPQZWBfDzzlERLQgpMRE&t=00h06m05s) You can now select testing 123 that you just created from the user list In the above field simply click on the blue user icon Click here and you can type in that testing 123 click Search And there is the user created and we click enter You see that it basically used a very strange conversion here Basically converting the username away from the numbers now you can you can fix that By clicking edit [00:06:40](https://www.youtube.com/watch?v=ckFakaQ90JY&list=PLQRGFI8XZ_wtGvPQZWBfDzzlERLQgpMRE&t=00h06m40s) And then changing it to 123 and say save the update Does not want to allow that. So clearly my little application doesn't wanna allow you to use actually any numbers in the user name,.That's not the point The point is that we have this integrated user now that is connected to an expert And if you were to click there again You can still selected ok but once you select it once you can't create a new expert And select that user again So it's basically one profile connecting to one user To set up a expert [00:07:24](https://www.youtube.com/watch?v=ckFakaQ90JY&list=PLQRGFI8XZ_wtGvPQZWBfDzzlERLQgpMRE&t=00h07m24s) So that's the feature I'm using it for there is different ways that I have implemented this let me show you another one Obviously you realise I'm using a lot of JavaScript on this page I will show you some of that JavaScript but That yourself Ok let me just get out of here for Example over here I wrote this job tracking Extension And let's say we want to create a new job order then I can say whether it's a new client or a existing if it is an existing I Simply select from this list [00:08:04](https://www.youtube.com/watch?v=ckFakaQ90JY&list=PLQRGFI8XZ_wtGvPQZWBfDzzlERLQgpMRE&t=00h08m04s) If it's new I click here I can enter all the details of the user and when I click save It Creates the user Stores the data in the user table not in the job order table deletes all these values So did the job order table never stores any user values in the relation of this job order of course And so that's another way that I have implemented so if we were to close this out And where to open a client A new one You would see it's basically it's the same values And [00:08:44](https://www.youtube.com/watch?v=ckFakaQ90JY&list=PLQRGFI8XZ_wtGvPQZWBfDzzlERLQgpMRE&t=00h08m44s) Everything is the same So that's another way that we integrated this whole User integration So there are really many different ways to this The way I have done it I've just listen to my clients expectation What I really would like to see and how they would like it to work And then simply Make It Happen that way I personally I prefer the Ajax Way much more It's it's just seems to me easier So let me illustrate some of or let me show you some of the code that I used to do that [00:09:26](https://www.youtube.com/watch?v=ckFakaQ90JY&list=PLQRGFI8XZ_wtGvPQZWBfDzzlERLQgpMRE&t=00h09m26s) Ok so we back in The Experts View As I've done before I previously in other tutorials explained how to make use of the Ajax concept Within Component Builder Now for those of you that like to understand what's going on let me give you a quick runover At the code level Within every component that makes use of Ajax A model and a controller is created The controller is named Ajax.json.php and the model is named [00:10:04](https://www.youtube.com/watch?v=ckFakaQ90JY&list=PLQRGFI8XZ_wtGvPQZWBfDzzlERLQgpMRE&t=00h10m04s) Ajax Ok let me open the model And also let me open The controller As you can see the controller basic fires off The register tasks within the construct method And then it adds the tasks Into a switch And tries to run the task basically Also in [00:10:31](https://www.youtube.com/watch?v=ckFakaQ90JY&list=PLQRGFI8XZ_wtGvPQZWBfDzzlERLQgpMRE&t=00h10m31s) The model it It Gets the model Ajax And then runs the method that basically corresponds to the task And so that is how It runs It uses the Joomlas default Filtering Method in the way that it gets values that are being posted And then value dates that those values actually are there Then sends the values over to the model [00:11:05](https://www.youtube.com/watch?v=ckFakaQ90JY&list=PLQRGFI8XZ_wtGvPQZWBfDzzlERLQgpMRE&t=00h11m05s) Now that's looking at it from a code side so if you look at the model It simply shows you Various methods Some of them are protected And some of them are public and those are usually the ones That gets called from the controller once the Ajax gets the Verification level and it's Verified So here is the create user class [00:11:31](https://www.youtube.com/watch?v=ckFakaQ90JY&list=PLQRGFI8XZ_wtGvPQZWBfDzzlERLQgpMRE&t=00h11m31s) Basically We first check Whether this user now this is custom script I mean this I wrote custom component build does not write this so Basically when you go back to the user interface You see that If I scroll down here create user fields And then there's great user You see that I wrote this right here And that basically gets placed into the model [00:12:07](https://www.youtube.com/watch?v=ckFakaQ90JY&list=PLQRGFI8XZ_wtGvPQZWBfDzzlERLQgpMRE&t=00h12m07s) So that's the Ajax method here I simply in that Ajax input I annotate the specific tasks The task name And specific variables And again the method name You could have different method names from task names and What should be validated whether it's integer, float or whatever And if there's no value What is the value by Default So this is where you set up there basically the controllers information [00:12:39](https://www.youtube.com/watch?v=ckFakaQ90JY&list=PLQRGFI8XZ_wtGvPQZWBfDzzlERLQgpMRE&t=00h12m39s) And then here your customised these write your script so basically create user gets data and seems from what view is it then validates with this current login user has the permission To actually The Experts area Then it Converts the data because it's a json set of datasets that I'm sending across So that we can see if it's an array does some other checks So you can see I'm still here I'm using that [00:13:17](https://www.youtube.com/watch?v=ckFakaQ90JY&list=PLQRGFI8XZ_wtGvPQZWBfDzzlERLQgpMRE&t=00h13m17s) Global helper Class and methods Here are number of custom methods obviously that That is available in that class to go through it we just added in there as freebies and And you wanna always see the Need of them but I'm using them often And even if you have with Improvements on those methods please make a pull request and we'll make those changes Then you over here once we've Become very sure that we've got enough data on the right data We basically get that same method and we need to create user [00:13:55](https://www.youtube.com/watch?v=ckFakaQ90JY&list=PLQRGFI8XZ_wtGvPQZWBfDzzlERLQgpMRE&t=00h13m55s) Get result And if it's not the correct result we deal with it accordingly And if it is the correct result we create Add the user to the user group That's something that the user does not that you create user does not do So we Then have a user group setup [00:14:17](https://www.youtube.com/watch?v=ckFakaQ90JY&list=PLQRGFI8XZ_wtGvPQZWBfDzzlERLQgpMRE&t=00h14m17s) And Basically in the component And we get that user group Set into the correct User Group This is a return message If it's an error or whether it's a Success So down here is the error message So if it's if it's successful this is what we do if it's unsuccessful this is what we do [00:14:45](https://www.youtube.com/watch?v=ckFakaQ90JY&list=PLQRGFI8XZ_wtGvPQZWBfDzzlERLQgpMRE&t=00h14m45s) And so that's just a quick look I mean obviously we can pause this video and Look at What I have done And then here is getUser when the page loads initially we get the id get the data packs it into some html And sends it off So This is the PHP side obviously We we do this create user and then there is a ajax [00:15:16](https://www.youtube.com/watch?v=ckFakaQ90JY&list=PLQRGFI8XZ_wtGvPQZWBfDzzlERLQgpMRE&t=00h15m16s) Site right in Javascript So In the JavaScript when the page loads Would you get user with the user ID We get the user ID from the field And then it loads that data that you saw If you if you looked no this is the wrong place Basically shows you that is the data it loads And that data can be edited Except over here [00:15:51](https://www.youtube.com/watch?v=ckFakaQ90JY&list=PLQRGFI8XZ_wtGvPQZWBfDzzlERLQgpMRE&t=00h15m51s) You cannot add numbers in the username but you can do that and it will update it as you see and will say that is updated it Obviously if there is a Error with the email already used or something it will also give you an error And this is all part of how we basically have setup the JavaScript Ok we can scroll down to So I've just added to Javascript to the view file And here is get user the server side and there is the the function [00:16:24](https://www.youtube.com/watch?v=ckFakaQ90JY&list=PLQRGFI8XZ_wtGvPQZWBfDzzlERLQgpMRE&t=00h16m24s) I have two functions usually one that sort of deals with Waiting and then eventually setting up the data into the The View And here's one making the call so this is how you call structure would usually look In index. php ?option = your components name And the task which Must go to the Ajax controller And then this is the task [00:16:54](https://www.youtube.com/watch?v=ckFakaQ90JY&list=PLQRGFI8XZ_wtGvPQZWBfDzzlERLQgpMRE&t=00h16m54s) And you then here can stipulate what format you would like the result set returned in if you Want the result set returned the raw which in sometime sometimes is the case There is if you look here There is a raw Variable You can just set the raw variable to true Then it will give you the results set just Like that without Braces around them [00:17:23](https://www.youtube.com/watch?v=ckFakaQ90JY&list=PLQRGFI8XZ_wtGvPQZWBfDzzlERLQgpMRE&t=00h17m23s) Or a call back or anything You see when you make calls from JavaScript It usually Wants this call back to be added If you make calls from other JavaScript libraries you might just want the braces around it But if you want it raw which also is often the case you just add the variable raw to the URL = true and then end up passing it back to you with this So that's a little heads up on Ajax function so [00:17:56](https://www.youtube.com/watch?v=ckFakaQ90JY&list=PLQRGFI8XZ_wtGvPQZWBfDzzlERLQgpMRE&t=00h17m56s) the format must json that's Important Ok and always use a token Have the token on the page this token is necessary To prevent cross site scripting of course I usually add the token to the page Through the Java oh sorry php So there is a place down here if you scroll down where is it I just remembered remembered [00:18:28](https://www.youtube.com/watch?v=ckFakaQ90JY&list=PLQRGFI8XZ_wtGvPQZWBfDzzlERLQgpMRE&t=00h18m28s) If you are working in a backend The backend the backend and the admin area you don't need to have the token its get added to the page dynamically Since we Basically parsed the JavaScript Areas And if we see token we actually know oh token is to be there and we add the token for you Where is the front end you must actually literally add the token There was just too many reasons for us Not to do the Automation in the front end so but you could literally change to the variable name as well [00:19:03](https://www.youtube.com/watch?v=ckFakaQ90JY&list=PLQRGFI8XZ_wtGvPQZWBfDzzlERLQgpMRE&t=00h19m03s) To something of your choice Where is now it's just token it's backend it's more secure ok so You need to always add a token To the request and check whether the token is there if it's not that it wouldn't make a request at all Ok so I was looking at another function there Ok so that's simply how we create a user And integrate the user concept within this component I hope that was helpful I realize if you not that fluent in programming in JavaScript Or in jQuery [00:19:41](https://www.youtube.com/watch?v=ckFakaQ90JY&list=PLQRGFI8XZ_wtGvPQZWBfDzzlERLQgpMRE&t=00h19m41s) As well as in PHP This might not fully resolved your questions Like I said where the beginning of these tutorials I wasn't planning on making a component that is Very easy to use but rather a Component that is very powerful to use And leaving it up to you to decide how to implement This user integration Is really the most powerful way of doing it At least we are adding the the class with which you can create the user And again even there you can go look at that class [00:20:20](https://www.youtube.com/watch?v=ckFakaQ90JY&list=PLQRGFI8XZ_wtGvPQZWBfDzzlERLQgpMRE&t=00h20m20s) If you feel my implementation is a little you know needs some Inprovement You can either shoot me a mail or you could Take For this component Builder on GitHub Pull down to your own repository Make the changes push it back And The place inside Of component builder where this class is constructed [00:20:47](https://www.youtube.com/watch?v=ckFakaQ90JY&list=PLQRGFI8XZ_wtGvPQZWBfDzzlERLQgpMRE&t=00h20m47s) is obviously Within The compilers files. Now the compiler Has Has quite a few files and you need to do do a search So you basically go to component Builder go to helper and then Use the compiler And here is all its files So do a search in here [00:21:09](https://www.youtube.com/watch?v=ckFakaQ90JY&list=PLQRGFI8XZ_wtGvPQZWBfDzzlERLQgpMRE&t=00h21m09s) For the function Create user you could you know just search for that and I'm sure you're fine it and it is in that area where you need to make the adaptation and the changes because it's dynamically added It is not it can't be edited like right in the script it needs to be edit in the function where we add it Just go search those functions [00:21:38](https://www.youtube.com/watch?v=ckFakaQ90JY&list=PLQRGFI8XZ_wtGvPQZWBfDzzlERLQgpMRE&t=00h21m38s) Thank you for watching That's how you create users and connect them to your components Obviously there is much more to say but I'm afraid this will get way too long like most of my tutorials get to long I want to keep it this this way and trying to make it shorter hope you enjoyed that +HOW TO INTEGRATE THE CREATE USER HELPER METHOD IN YOUR COMPONENTS + + +Hi. I would like to give you a quick tutorial or demonstration on how to use the user creation method or function in your component. What is the user creation function? [00:00:18](https://www.youtube.com/watch?v=ckFakaQ90JY&list=PLQRGFI8XZ_wtGvPQZWBfDzzlERLQgpMRE&t=00h00m18s) It is basically a part of code's helper function that gets added to the helper class. + +### Helper Class + +If you don't know where the helper class is let me quickly show you. If you go to your repository where you find your Joomla install, you would go to administrator. There is a helper class for the front end of every component as well as for the back end. Looking in a back end, we go to component, [00:00:55](https://www.youtube.com/watch?v=ckFakaQ90JY&list=PLQRGFI8XZ_wtGvPQZWBfDzzlERLQgpMRE&t=00h00m55s) expertdatabase You go to helpers, it's basically that file there, that is the helper class. If we open it we see that it's the abstract expertdatabasehelper. That helper class gets included into your component on every page. If you were to open the main back end file with that one(expertdatabase), which get loaded by Joomla first. You'll see that it actually includes that helper file in every page. [00:01:28](https://www.youtube.com/watch?v=ckFakaQ90JY&list=PLQRGFI8XZ_wtGvPQZWBfDzzlERLQgpMRE&t=00h01m28s) So that means everything inside of that class is available to you everywhere in your component. When we actually go back to our interface, we go to components and then expertdatabase. You would see that there is library and helpers. We have this switch ticked yes, 'add create user helper method', set to yes. That is the [00:02:11](https://www.youtube.com/watch?v=ckFakaQ90JY&list=PLQRGFI8XZ_wtGvPQZWBfDzzlERLQgpMRE&t=00h02m11s) switch that you need to trip, that component builder knows that you actually want the helper class that creates users to be added to the helper class of your front and back end of your component. I'm going to close out here. I am going to go back to the code. Then I am going to do a simple search for user. [00:02:44](https://www.youtube.com/watch?v=ckFakaQ90JY&list=PLQRGFI8XZ_wtGvPQZWBfDzzlERLQgpMRE&t=00h02m44s) + +### Create User + +Here is quite a few users, there it is create user. As you can see this is a public static function. So you would basically call it with that class name(expertdatabasehelper) then colon colon and the name of the function, which is create user. You will see that it is set to 'new'. [00:03:26](https://www.youtube.com/watch?v=ckFakaQ90JY&list=PLQRGFI8XZ_wtGvPQZWBfDzzlERLQgpMRE&t=00h03m26s) Now new has in it a few variables is basically an array. You can go through this class and you'd see that it has a password, password2, it has a user name, it has a name, aswell as a e-mail. Then it creates the user, that's what this class does. It calls in the Joomla component users. [00:04:00](https://www.youtube.com/watch?v=ckFakaQ90JY&list=PLQRGFI8XZ_wtGvPQZWBfDzzlERLQgpMRE&t=00h04m00s) It calls in it's registration model. And then it basically uses that model to create a user. That's what that switch does, it adds this class to your component. You can then use it in your component. It doesn't automatically just sets everything else in place, you still required to do as a developer to add to correct code. I'll show you what I have done and how I am using it. + +### Expert Field + +There is a admin view called experts. It's in this view that I would actually like the option for someone to create a user. Let me first demonstrate how it works. I would go to expertdatabase and click on experts. Let's click on new. So you would see there is a [00:04:55](https://www.youtube.com/watch?v=ckFakaQ90JY&list=PLQRGFI8XZ_wtGvPQZWBfDzzlERLQgpMRE&t=00h04m55s) field called expert which you can select users within a specific group. I will also explain some of that more later. But underneath there is this button create user. If you click on it, it basically has a pop-up where in you enter a user name. I am just going to say 'Testing123' as the username. [00:05:26](https://www.youtube.com/watch?v=ckFakaQ90JY&list=PLQRGFI8XZ_wtGvPQZWBfDzzlERLQgpMRE&t=00h05m26s) And as the password, there we go, got the user name. So everything is testing123. If I click create, it basically has this nice effect where it is busy creating it, setting it up, sending out the email, doing all of that for you. And once it's done it lets you know that the user was created successfully and the login details was e-mailed to the user. Then it says here ready to select. [00:06:05](https://www.youtube.com/watch?v=ckFakaQ90JY&list=PLQRGFI8XZ_wtGvPQZWBfDzzlERLQgpMRE&t=00h06m05s) You can now select testing123 that you just created from the user list in the above field. Simply click on the blue user icon. Click here and you can type in that testing123 click search. There is the user created and we click enter. You see that it basically used a very strange conversion here. Basically converting the username away from the numbers. Now you can you can fix that by clicking edit. [00:06:40](https://www.youtube.com/watch?v=ckFakaQ90JY&list=PLQRGFI8XZ_wtGvPQZWBfDzzlERLQgpMRE&t=00h06m40s) +??? +And then changing it to 123 and say save the update Does not want to allow that. So clearly my little application doesn't wanna allow you to use actually any numbers in the user name,.That's not the point The point is that we have this integrated user now that is connected to an expert And if you were to click there again You can still selected ok but once you select it once you can't create a new expert And select that user again So it's basically one profile connecting to one user To set up a expert [00:07:24](https://www.youtube.com/watch?v=ckFakaQ90JY&list=PLQRGFI8XZ_wtGvPQZWBfDzzlERLQgpMRE&t=00h07m24s) So that's the feature I'm using it for there is different ways that I have implemented this let me show you another one Obviously you realise I'm using a lot of JavaScript on this page I will show you some of that JavaScript but That yourself Ok let me just get out of here for Example over here I wrote this job tracking Extension And let's say we want to create a new job order then I can say whether it's a new client or a existing if it is an existing I Simply select from this list [00:08:04](https://www.youtube.com/watch?v=ckFakaQ90JY&list=PLQRGFI8XZ_wtGvPQZWBfDzzlERLQgpMRE&t=00h08m04s) If it's new I click here I can enter all the details of the user and when I click save It Creates the user Stores the data in the user table not in the job order table deletes all these values So did the job order table never stores any user values in the relation of this job order of course And so that's another way that I have implemented so if we were to close this out And where to open a client A new one You would see it's basically it's the same values And [00:08:44](https://www.youtube.com/watch?v=ckFakaQ90JY&list=PLQRGFI8XZ_wtGvPQZWBfDzzlERLQgpMRE&t=00h08m44s) Everything is the same So that's another way that we integrated this whole User integration So there are really many different ways to this The way I have done it I've just listen to my clients expectation What I really would like to see and how they would like it to work And then simply Make It Happen that way I personally I prefer the Ajax Way much more It's it's just seems to me easier So let me illustrate some of or let me show you some of the code that I used to do that [00:09:26](https://www.youtube.com/watch?v=ckFakaQ90JY&list=PLQRGFI8XZ_wtGvPQZWBfDzzlERLQgpMRE&t=00h09m26s) Ok so we back in The Experts View As I've done before I previously in other tutorials explained how to make use of the Ajax concept Within Component Builder Now for those of you that like to understand what's going on let me give you a quick runover At the code level Within every component that makes use of Ajax A model and a controller is created The controller is named Ajax.json.php and the model is named [00:10:04](https://www.youtube.com/watch?v=ckFakaQ90JY&list=PLQRGFI8XZ_wtGvPQZWBfDzzlERLQgpMRE&t=00h10m04s) Ajax Ok let me open the model And also let me open The controller As you can see the controller basic fires off The register tasks within the construct method And then it adds the tasks Into a switch And tries to run the task basically Also in [00:10:31](https://www.youtube.com/watch?v=ckFakaQ90JY&list=PLQRGFI8XZ_wtGvPQZWBfDzzlERLQgpMRE&t=00h10m31s) The model it It Gets the model Ajax And then runs the method that basically corresponds to the task And so that is how It runs It uses the Joomlas default Filtering Method in the way that it gets values that are being posted And then value dates that those values actually are there Then sends the values over to the model [00:11:05](https://www.youtube.com/watch?v=ckFakaQ90JY&list=PLQRGFI8XZ_wtGvPQZWBfDzzlERLQgpMRE&t=00h11m05s) Now that's looking at it from a code side so if you look at the model It simply shows you Various methods Some of them are protected And some of them are public and those are usually the ones That gets called from the controller once the Ajax gets the Verification level and it's Verified So here is the create user class [00:11:31](https://www.youtube.com/watch?v=ckFakaQ90JY&list=PLQRGFI8XZ_wtGvPQZWBfDzzlERLQgpMRE&t=00h11m31s) Basically We first check Whether this user now this is custom script I mean this I wrote custom component build does not write this so Basically when you go back to the user interface You see that If I scroll down here create user fields And then there's great user You see that I wrote this right here And that basically gets placed into the model [00:12:07](https://www.youtube.com/watch?v=ckFakaQ90JY&list=PLQRGFI8XZ_wtGvPQZWBfDzzlERLQgpMRE&t=00h12m07s) So that's the Ajax method here I simply in that Ajax input I annotate the specific tasks The task name And specific variables And again the method name You could have different method names from task names and What should be validated whether it's integer, float or whatever And if there's no value What is the value by Default So this is where you set up there basically the controllers information [00:12:39](https://www.youtube.com/watch?v=ckFakaQ90JY&list=PLQRGFI8XZ_wtGvPQZWBfDzzlERLQgpMRE&t=00h12m39s) And then here your customised these write your script so basically create user gets data and seems from what view is it then validates with this current login user has the permission To actually The Experts area Then it Converts the data because it's a json set of datasets that I'm sending across So that we can see if it's an array does some other checks So you can see I'm still here I'm using that [00:13:17](https://www.youtube.com/watch?v=ckFakaQ90JY&list=PLQRGFI8XZ_wtGvPQZWBfDzzlERLQgpMRE&t=00h13m17s) Global helper Class and methods Here are number of custom methods obviously that That is available in that class to go through it we just added in there as freebies and And you wanna always see the Need of them but I'm using them often And even if you have with Improvements on those methods please make a pull request and we'll make those changes Then you over here once we've Become very sure that we've got enough data on the right data We basically get that same method and we need to create user [00:13:55](https://www.youtube.com/watch?v=ckFakaQ90JY&list=PLQRGFI8XZ_wtGvPQZWBfDzzlERLQgpMRE&t=00h13m55s) Get result And if it's not the correct result we deal with it accordingly And if it is the correct result we create Add the user to the user group That's something that the user does not that you create user does not do So we Then have a user group setup [00:14:17](https://www.youtube.com/watch?v=ckFakaQ90JY&list=PLQRGFI8XZ_wtGvPQZWBfDzzlERLQgpMRE&t=00h14m17s) And Basically in the component And we get that user group Set into the correct User Group This is a return message If it's an error or whether it's a Success So down here is the error message So if it's if it's successful this is what we do if it's unsuccessful this is what we do [00:14:45](https://www.youtube.com/watch?v=ckFakaQ90JY&list=PLQRGFI8XZ_wtGvPQZWBfDzzlERLQgpMRE&t=00h14m45s) And so that's just a quick look I mean obviously we can pause this video and Look at What I have done And then here is getUser when the page loads initially we get the id get the data packs it into some html And sends it off So This is the PHP side obviously We we do this create user and then there is a ajax [00:15:16](https://www.youtube.com/watch?v=ckFakaQ90JY&list=PLQRGFI8XZ_wtGvPQZWBfDzzlERLQgpMRE&t=00h15m16s) Site right in Javascript So In the JavaScript when the page loads Would you get user with the user ID We get the user ID from the field And then it loads that data that you saw If you if you looked no this is the wrong place Basically shows you that is the data it loads And that data can be edited Except over here [00:15:51](https://www.youtube.com/watch?v=ckFakaQ90JY&list=PLQRGFI8XZ_wtGvPQZWBfDzzlERLQgpMRE&t=00h15m51s) You cannot add numbers in the username but you can do that and it will update it as you see and will say that is updated it Obviously if there is a Error with the email already used or something it will also give you an error And this is all part of how we basically have setup the JavaScript Ok we can scroll down to So I've just added to Javascript to the view file And here is get user the server side and there is the the function [00:16:24](https://www.youtube.com/watch?v=ckFakaQ90JY&list=PLQRGFI8XZ_wtGvPQZWBfDzzlERLQgpMRE&t=00h16m24s) I have two functions usually one that sort of deals with Waiting and then eventually setting up the data into the The View And here's one making the call so this is how you call structure would usually look In index. php ?option = your components name And the task which Must go to the Ajax controller And then this is the task [00:16:54](https://www.youtube.com/watch?v=ckFakaQ90JY&list=PLQRGFI8XZ_wtGvPQZWBfDzzlERLQgpMRE&t=00h16m54s) And you then here can stipulate what format you would like the result set returned in if you Want the result set returned the raw which in sometime sometimes is the case There is if you look here There is a raw Variable You can just set the raw variable to true Then it will give you the results set just Like that without Braces around them [00:17:23](https://www.youtube.com/watch?v=ckFakaQ90JY&list=PLQRGFI8XZ_wtGvPQZWBfDzzlERLQgpMRE&t=00h17m23s) Or a call back or anything You see when you make calls from JavaScript It usually Wants this call back to be added If you make calls from other JavaScript libraries you might just want the braces around it But if you want it raw which also is often the case you just add the variable raw to the URL = true and then end up passing it back to you with this So that's a little heads up on Ajax function so [00:17:56](https://www.youtube.com/watch?v=ckFakaQ90JY&list=PLQRGFI8XZ_wtGvPQZWBfDzzlERLQgpMRE&t=00h17m56s) the format must json that's Important Ok and always use a token Have the token on the page this token is necessary To prevent cross site scripting of course I usually add the token to the page Through the Java oh sorry php So there is a place down here if you scroll down where is it I just remembered remembered [00:18:28](https://www.youtube.com/watch?v=ckFakaQ90JY&list=PLQRGFI8XZ_wtGvPQZWBfDzzlERLQgpMRE&t=00h18m28s) If you are working in a backend The backend the backend and the admin area you don't need to have the token its get added to the page dynamically Since we Basically parsed the JavaScript Areas And if we see token we actually know oh token is to be there and we add the token for you Where is the front end you must actually literally add the token There was just too many reasons for us Not to do the Automation in the front end so but you could literally change to the variable name as well [00:19:03](https://www.youtube.com/watch?v=ckFakaQ90JY&list=PLQRGFI8XZ_wtGvPQZWBfDzzlERLQgpMRE&t=00h19m03s) To something of your choice Where is now it's just token it's backend it's more secure ok so You need to always add a token To the request and check whether the token is there if it's not that it wouldn't make a request at all Ok so I was looking at another function there Ok so that's simply how we create a user And integrate the user concept within this component I hope that was helpful I realize if you not that fluent in programming in JavaScript Or in jQuery [00:19:41](https://www.youtube.com/watch?v=ckFakaQ90JY&list=PLQRGFI8XZ_wtGvPQZWBfDzzlERLQgpMRE&t=00h19m41s) As well as in PHP This might not fully resolved your questions Like I said where the beginning of these tutorials I wasn't planning on making a component that is Very easy to use but rather a Component that is very powerful to use And leaving it up to you to decide how to implement This user integration Is really the most powerful way of doing it At least we are adding the the class with which you can create the user And again even there you can go look at that class [00:20:20](https://www.youtube.com/watch?v=ckFakaQ90JY&list=PLQRGFI8XZ_wtGvPQZWBfDzzlERLQgpMRE&t=00h20m20s) If you feel my implementation is a little you know needs some Inprovement You can either shoot me a mail or you could Take For this component Builder on GitHub Pull down to your own repository Make the changes push it back And The place inside Of component builder where this class is constructed [00:20:47](https://www.youtube.com/watch?v=ckFakaQ90JY&list=PLQRGFI8XZ_wtGvPQZWBfDzzlERLQgpMRE&t=00h20m47s) is obviously Within The compilers files. Now the compiler Has Has quite a few files and you need to do do a search So you basically go to component Builder go to helper and then Use the compiler And here is all its files So do a search in here [00:21:09](https://www.youtube.com/watch?v=ckFakaQ90JY&list=PLQRGFI8XZ_wtGvPQZWBfDzzlERLQgpMRE&t=00h21m09s) For the function Create user you could you know just search for that and I'm sure you're fine it and it is in that area where you need to make the adaptation and the changes because it's dynamically added It is not it can't be edited like right in the script it needs to be edit in the function where we add it Just go search those functions [00:21:38](https://www.youtube.com/watch?v=ckFakaQ90JY&list=PLQRGFI8XZ_wtGvPQZWBfDzzlERLQgpMRE&t=00h21m38s) Thank you for watching That's how you create users and connect them to your components Obviously there is much more to say but I'm afraid this will get way too long like most of my tutorials get to long I want to keep it this this way and trying to make it shorter hope you enjoyed that