In this first tutorial I'll explain how to handle custom userprofile advanced crud functionality in FreakAuth_light 1.0.2-Beta .
I assume you have already installed both CI 1.5.2 and FreakAuth_light 1.0.2-Beta and that you are a bit familiar with them.
If you wanna play with custom userprofile in FreakAuth_light you should also have it enable in the FreakAith_light configuration:
It's furthermore important that You understood the way CI handles form validation.
Well as the name suggests the custom userprofile CRUD is a functionality similar to CI SCAFFOLDING. While with the CI SCAFFOLDING is more general and scaffolds every table of your DB providing a general functionality, the custom userprofile CRUD is related to the user_profile table of your database. Compared to the CI SCAFFOLDING the custom userprofile CRUD has the advantage of allowing to set your validation fields and validation rules.
The custom userprofile has been designed to allow to easily handle the need to add custom descriptions fields for your registered users besides:
One thing is really important: the custom userprofile CRUD is an additional feature that should simplify your programming life. If you don't understand its functionality you can always build your controllers in the traditional way with CI validation, and DB select/insert/update functionalities.
To use the CUSTOM USERPROFILE CRUD of FreakAuth_light we need to:
Use your DB management software (phpMyAdmin I guess) to add your needed fields.
You can call your fields as you like and define them as you like in terms of data type.
Open your application/config/freakauth_light.php and go at the end of the file where you will find the following
The first array $config['FAL_user_profile_fields_names'] specifies :
The second array $config['FAL_user_profile_fields_validation_rules'] specifies:
Therefore, summarising in both config arrays the $key refers to the name of the field in DB. If You:
iin your config arrays You should write:
What if you have add the fields in DB and you have forgotten to add them in the config file application/config/freakauth_light.php?!?
Well no probs! The system will automagically bring the fields from DB if You didn't define them in the config of if you set less rules/fields in config with respect to the number of the fields in the table user_profile.
the system will use the table field name as field for the table fields not ruled in config, and won't set any rule for them.
If you want to use language file definitions in defining your labels you should add the following line before the array $config['FAL_user_profile_fields_names']
Well if you followed the above steps properly you should now see all the custom user_profile fields when you view/edit and user from the backend.
To see your changes in the backend administration you don't need to change a line in the admin/users.php file!
We can use the custom userprofile crud in two circumstances for frontend:
Case 1 presents two problems in order to be fully authomathed with FAL custom userprofile CRUD:
I'll present some solutions to case 1 in next tutorial.
Considering case 2 let's see how we can easily build a frontend controller to show the user custom profile and to allow the owner of the profile to edit it.
I will consider case 2 in the second part of this tutorial.