Can I create a custom WordPress registration form? - php

I want to have in WordPress two kind of registration forms. The default one for let's say visitors users and a custom one for some more privileged users. How can I make the custom one? I especially need the part with the roles, the custom reg form will have another role for the users that will register to it. How can I do that? I think I need something like(it's just a fabulation, don't know the real functions from WordPress)
Example:
//the following variables will be a part of the form that will stand above this function
add_user('$username','$mail','$location','$region','$role');
//where $role can be {1(subscribers),2(contrib.),3(authors),4(editor),5(admin)}
Can I do something like that?

You can use Gravity Forms to create your registration forms with the User Registration add-on and specify custom user meta (including roles.) If you would like to create a custom form without a plugin, you should not attempt to add users directly to the database, instead you should use the wp_create_user function. From the WordPress Codex:
The wp_create_user function allows you to insert a new user into the
WordPress database. It uses the $wpdb class to escape the variable
values, preparing it for insertion into the database. Then the PHP
compact() function is used to create an array with these values. To
create a user with additional parameters, use wp_insert_user().

You can install a webform module in wordpress. Selected an existing form and customize the fields as per your requirement.

Related

Moodle custom fields API for course page

Unfortunately I can't quite follow how the custom field API works. What I actually want are additional fields for the custom course format such as address, directions and other (hybrid courses). And no, I don't want to use the web interface for this.
As I understand it, two files are needed, myFormatPlugin/classes/customfields/course_handler.php
and
myFormatPlugin/customfield.php
Do I need to register the customfield.php file somewhere or does it work via autoload?
Do I need to create a separate database table for this?
What am I missing?
Could someone make an example for just one field? I don't find the github links in the documentation helpful either.
Hope you want to add some custom fields for your custom course format. To add custom fields for the format plugin you don't want to use the custom field API.
The course format plugin contains options to add your custom fields using the function course_format_options in your course/format/PLUGINNAME/lib.php.
Moodle will automatically store these custom course format options in the database table course_format_options.
Please have look at the designer course format plugin.
https://github.com/bdecentgmbh/moodle-format_designer/blob/master/lib.php#L241

Wordpress ask user's their desired role as a dropdown menu while registration

I want to add a custom field to the Wordpress registration form without using any plugins. I want to add a dropdown menu with user-roles ( some roles I have created). Once the registration is complete the user should not have the ability to change their roles ( only admin can do that, selecting role as admin should not be allowed).
Any help will be appreciated.
I understand that you do not intend to use plugins, but you nevertheless use a theme, be it implemented by your team or some widely available theme. In any case, that theme has an implementation for your registration, so:
Find the registration form
Make sure that you find out where the registration form is.
Add a field to the form
Be it in a CMS editor or in a PHP/HTML file you must be able to edit it and add a field
Find the code which runs when a registration is posted
Again, you need to seek and find.
Enhance your functionalities which save fields
You will need to track and save the posted value
Change the database schema
You will need to do some changes on the MySQL schema in order to support the new field on database-level.

Joomla additional User Data

Im trying to create some new extensions in joomla.
I want to add additional information for each user. I know I could achieve this by creating my own custom user profile plugin and adding additional fields, but this will then add those fields to the users profile page.
I want to show the new fields separately. For example i may have one link on the users page which takes them to there basic information e.g. name, email etc. And another link which shows them the 'additional' fields.
The additional fields will not be personal information, that's why I want to display them separately.
My question is, how do I achieve this? Can I simply add additional fields to each user or will I have to write a completely new component?
UPDATE: I cannot use an existing extension as I want full control over the code. Also, the additional information will NOT be added by the user, it will only be added by admin.
You do not have to display profile fields on the user profile page with the standard user profile You can configure it only to display to the administrator. You simply make different settings for the different forms (there are 4 throughout the cms). Follow the pattern in the core plugin.
In the end I decided it was better to create my own component. Mainly because hacking joomla would be a pest when updates came out and JED did not provide the specific extension that I wanted.
There are probably 2 main way of doing this.
You can create an extension where user fill in the information and it stores the data in separate database table which connects to the #__users table.
You could download an extension from JED for extended profiles. There are non-commercial and commercial extensions so take a look here to see if there is anything that might suit your needs.
Personally I would install a pre-made extension and it will save a lot of work/trial and error.
check this out: http://extensions.joomla.org/extensions/clients-a-communities/user-management
If you have added or changed any coding like adding fields to user table or customize registration page in joomla it will restore to default once you upgrade your Joomla version.
The way to do this is:
You have to create another table which contains the other extra information and should with userid from #__users.
When submitting the form you have get the another table by using this Joomla code.
$module_table = JTable::getInstance('modules', 'profileTable');
Modules -> means table name which you created.
ProfileTable -> means "component name" is Model name and "Table" is common.
Then you have to pass the post values to this table like this..
if (!$module_table->bind($post))
{
return 0;
}
if (!$module_table->check())
{
return 0;
}
if (!$module_table->store())
{
return 0;
}
This way, you can store additional data for users. For displaying purposes, you will need to join the two tables by using userid and display it...
All the best..

Dynamic forms by user in php?

Here in my PHP application, I need to allow users to create a registration forms customized for themselves. They will be having the privilege of choosing the number fields, their names as well as there type. The table for the data also will be created dynamically in MySQL.
Now I want to know if there is any library out there which could lessen my work or will I have to do it the harder way?
Thanks.
Yo can try CROOGO dynamics forms a CakePHP CMS.
It is having a very good plugin where admin can customize it's form with validation facility and also relate two fields if required (eg: Password and confirm password should be same.
For core php. You to structure your db by using SAAS model.
refrence:http://stackoverflow.com/questions/5180803/what-kind-of-database-is-used-in-dynamic-form-builder

Drupal 6: custom profile fields and saving data to a DB

So i've added several some custom profile fields (administer -> profiles) which is all fine but completely useless if I can't store the information in a database. I've been searching for hours now trying to figure out the "best practices" way for doing this with very little luck.
Do I add the new columns to the Users table? Do I create a whole new table? I even found a vague reference that the core profile module should have added those columns for me anyway? And that you should be able to use CCK in the core profile module (but I don't have any options for that)?
And then I would obviously want to allow user to update their own fields but the the custom profile fields aren't included in the $form array...
PS arrrggg! Drupal is driving me around the bend with its inconsistencies and having to hack it all the time!
If you use the core profile module, the database storage is provided automatically and you will not need to modify anything in the database. On install, the module adds two tables to the database, profile_fields to store your custom field definitions and profile_values to store the user supplied data for those fields.
The fields are automatically added to the user edit forms, via the hook_user implementation in profile_user() - the same mechanism is used to add the values of those fields to the user object when that gets loaded.
So if those fields don't show up for you, something is fishy - have you added your fields with 'categories'? If so, they won't show on the standard user edit page, but on additional new pages (one per category). These are added as menu type MENU_LOCAL_TASK, so they should create new 'tab' entries at the top of the user edit page - maybe you have a theme that does not display the tabs?
Another thing to check would be the fields visibility settings chosen on the fields configuration form. If that is set to 'hidden', the field is only accessible for administrators and module/theme code. You should at least set it to 'private' if the user is supposed to edit it himself.
As for using CCK fields, I don't think that this is possible with the core profile module (maybe some extension module provides this). A different approach is taken by the Content Profile Module. It creates a custom node type for user profiles so that the profile values are stored as standard Drupal nodes. One advantage of this is that you can use all CCK fields for profiles, as you just need to add those to the created node type.

Categories