Adding custom field in default joomla 3.1.1 registration form - php

Recently I have stumbled upon a situation in Joomla 3.1.1 where I need to add a custom field attached with default registration form.
I surfed the existing resources which say that I should navigate to
joomla_root/components/com_users/models/forms/registration.xml and then change the file accordingly.
I have done that but nothing is showing up. I also need to change registration.php in model and controller too. So, I need your inputs on how to do that. I can't use profile plugin or commercial extensions.
One more thing that I've noticed is the fact that changing registration.xml file and such things work perfectly fine in Joomla 2.5 but isn't working in 3.x.

Joomla ships with a user plugin called "profile" which may contain the fields you want to add already.
In the administrator go to extensions/plugins, filter by type and choose "user", then find the "Profile" and open it. Check out the options on the right handside, enable the plugin and voila.
Warning: most templates override the registration form and they usually don't fire the correct plugin events. If this is the case, your users will only see the "standard" fields in the registration. And if you set any fields as required in the plugin, they will not be registered, but redirected to the complete registration page (the user component), where they will find the fields they already filled in except for the passwords, which can be quite annoying.
If the "profile" fields are not sufficient, copy the profile plugin and build your own.
Do NOT modify the profile plugin or com_users files like you have done, this is Joomla core and will be overwritten when you next upgrade.

Eventually it turns out that the problem was a component called K2.I tried this custom registration stuff in joomla 2.5 and then suddenly thought how about disabling K2 System Plugin..It worked.
Im posting the steps to do so:
1.Navigate to joomla_root/components/com_users/models/forms/registration.xml and add a field there.
2.Then open up joomla_root/components/com_users/models/registration.php and then in the function register() change ur custom fields.
3.Don't forget to add a field in ur database table #_users which you have added in registration.xml

Depending on whether you needed the custom field to be added to the database or not, you could use a form building component such as RSForm!Pro or ChronoForms. They both can tie into the user registration system in Joomla and give you a lot of flexibility in custom emails, adding info to database tables, etc. This would insulate you from any core updates that could wipe out your modifications. I believe Chronoforms is free as long as you don't mind a link back to the developers in the form.
If you can't do that, I would make sure that I had a backup of the files that I modified handy before updating the site. Joomla 3.1.x is a short term build so you have a higher risk of those files getting changed than if you were working on a Joomla 2.5.x site.

Related

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.

How to customize Plugins and Themes for WordPress

I am currently trying to build a website for a client using WordPress for a school project. The client requires a user system with a log in and storage of user permissions and information.I downloaded a plugin called Simple Membership because it had the best reviews for user membership plugins.
The biggest problem I am experiencing at the moment is the default contact information that comes with the plugin is not the information I wish to store. I need other fields to be stored. I am a developer so I first took a look at the code using FTP and made a few changes just to the registration form to show off to the client for the first iteration.
I have now been made aware that when updating the plugin all of my changes will be overridden. I am here to ask if there is an efficient way to make changes to a plugin without creating a new plugin(does not seem practical, I need to change the function of this plugin not just add to it). At the moment that is the only solution I am aware of. Can someone point me in the right direction?
It may not be the best solution but it's practical on your case.Take a backup of your formula plugin and re install it if a new update comes in.

Is it possible for a Joomla Form plugin to create a table and save form data to that table?

I am working on creating a Joomla based web service that is easy to use. The end goal is to allow customers the ability to manage the site from the front-end with no back-end (administrator) access. To accomplish this task I am using K2 that has existing front-end editing. Then behind the scenes we will provide technical support. Essentially, non-techy customers can easily manage their site, with us managing the tech side of things.
I need to provide a few forms (Contact, Event registration/payment and Donation payment). These forms also require that certain aspects of the forms can be updated via the front-end leveraging K2. (eg. The email address to send form submissions to.) With most forms components this can be done easily from the admin panel, however this is too complicated for non-techy customers and means we would have to provide admin access instead of just front-end. Not a good solution.
I have created a K2 contact Form plugin that will allow a customer to update where the email is sent on submission, when logged into the front-end with correct permissions. So far so good. I chose a plugin to accomplish this so we could leverage the existing front-end editing.
The issue I ran into is how to make my plugin create a table, preferably on install, as well as save form data to that table on successful submission. I'm not sure that this is possible using a plugin and have not found any documentation or sources mentioning how to accomplish this task.
I was hoping someone may be able to confirm either way if this is possible? Any suggestions, comments, etc would be greatly appreciated.
While installing plugin you can create DB tables, Its not a big deal create the SQL file with proper table query and set that inside your XML file.
Also you can create a forms(with many fields) inside your plugin file, But the problem is you should have any components controller and model related to this form submission task. Bcoz form submission you cannot handle inside plugin file, it should required a controller and model files.
So basically your plugin have related components then you can achieve it with form action like below.
<form action="index.php?option=com_yourcomponent&task=your_controller.your_function">
For creating DB table while installing plugin check this link
Hope its helps..

Force K2 registration and profile views to be used instead of the default registration and profile views?

I converted a site from 1.7 to 2.5, and all is really just about done, but I'm having one issue. I want to use these two custom K2 templates that existed in the previous version for both user registration and user profile because they were using K2 as the user registration mechanism.
I've configured K2 to Enable K2 User Profile:
but for whatever reason, when I navigate to index.php?option=com_users&view=register it's still grabbing the default registration form. Now, I thought it was maybe the URL, but the old 1.7 system is using the same URL. So, with some debugging I found that when the layout is told to search for a file, the K2 path isn't in the array.
What did I do wrong here?
NOTE: I also tried configuring the User Manager so that Allow User Registration was set to No, but I just get a 403 then because it's just not overriding with that K2 template.
UPDATE
As I stated in the comments, for whatever reason I don't have a K2 registration menu item type. However, the weirdest part is that the 1.7 version didn't point to the K2 registration either.
A little more background. This is a really hacked together system. The menu is actually built with a Jumi module that is straight forward custom and when the user is logged in the link that is used for the profile for example is this:
index.php?option=com_users&view=user&layout=form&id=3
and the register link, which is also custom (i.e. it's a link on a custom view) is this:
index.php?option=com_user&view=register
So, in short, I don't know enough about the Joomla navigation system to understand how to get those links to reroute to the K2 views that reside /components/com_k2/templates folder.
UPDATE
I put the register.php view that existed in /components/com_k2/templates folder into the /templates/tmplname/html/com_users/register folder and renamed it default.php so that the default user registration navigation would choose that view. And it did choose that view, no real surprise, but it also failed on a line like this:
<?php if(count(array_filter($this->K2Plugins))): ?>
because K2Plugins is null and that's not allowed for the array_filter function. I'm guessing this is because if this view were inside the com_k2 folder, like its original location, this would be available. I'm trying everything I can think of now.
It also threw on this line:
$this->K2Params->get('recaptchaOnRegistration')
because K2Params is null so of course get isn't available.
I found the problem, finally! The /plugins/system/k2/k2.php was catching the onAfterDispatch method for the navigation of com_users. If it was com_users and register or profile then it redirected and leveraged a different view. Well, the problem was that the old code said com_user instead of com_users. Silly!

Adding to a plugin with wordpress

I'm having major problems with this. Basically, I need to add a "url" field to the event management plugin with wordpress. My client wants to be able to add a url to their event so it can be clicked and viewed for more information on the event. I've looked through everything and im having problems understanding the wordpress file structure. I tried to add my own field to the event editor, database and front end but i dont know where wordpress posts the data to so i cant receive the variable. If i could get the variable, i could probably figure out how to use $wpdb relatively simply. but for that matter, i dont know where i should use that. where is the file that makes all those calls? i shouldnt have a problem getting the data from the database.
Edit
My problem, as described, was solved by installing another plugin called PODS. the only solution to adding functionality to a plugin, as in other fields, is to write your own plugin (as far as im aware). PODS solved my problem. It allowed me to add another field to the front of the event management form and saved it to the database. I still had to retrieve it from the database and display it on the front myself with php, but it was a much easier task than i expected it to be. If anybody wants to add extra fields to a plugin in wordpress, PODS is what i'd suggest. It's also free.

Categories