Adding new fields to mdl_user

Adding new fields to mdl_user

by subhajit maji -
Number of replies: 15

I want to add new fields to mdl_user and use external database plugin to import data to those fields. I dont want to use "User Profile Fields" since those can not be imported from external database.

Can anyone plz help?

Average of ratings: -
In reply to subhajit maji

Re: Adding new fields to mdl_user

by Anthony Borrow -
Picture of Core developers Picture of Plugin developers Picture of Testers
Subhajit - For adding the fields to the database, I would use phpmyadmin. There is a Moodle plugin version you can find at http://download.moodle.org/download.php/mysql/moodle-mysql-admin.zip. That said, I think you would be interested in voting for and/or watching MDL-10908 in the tracker as it sounds like a request for what you are looking for. Peace - Anthony
In reply to Anthony Borrow

Re: Adding new fields to mdl_user

by subhajit maji -

The link provided is not woking

Its saying:

Sorry, but the file you are looking for was not found! (http://download.moodle.org/mysql/moodle-mysql-admin.zip)

In reply to subhajit maji

Re: Adding new fields to mdl_user

by Anthony Borrow -
Picture of Core developers Picture of Plugin developers Picture of Testers
Sorry - I think this link and some others are not working following a repair of the download server. I have created MDLSITE-610 to try and get those links fixed. In the meantime, if you use CVS you can find the files at http://cvs.moodle.org/contrib/plugins/admin/mysql/ If you do not have access to CVS just send me an email to anthony [a t] moodle [d o t] org and I will send you a zip file. Peace - Anthony
In reply to Anthony Borrow

Re: Adding new fields to mdl_user

by subhajit maji -

Thanks for the quick reply.

In reply to subhajit maji

Re: Adding new fields to mdl_user

by Anthony Borrow -
Picture of Core developers Picture of Plugin developers Picture of Testers
Subhajit - I believe that the phpMyAdmin link is now working again. The file should be unzipped to your Moodle site's /admin/mysql directory. If the link is not working or you continue to have problems please let me know. Peace - Anthony
In reply to Anthony Borrow

Re: Adding new fields to mdl_user

by subhajit maji -
Thanks Anthony, the link is working. I am giving it a try and will let you know if I encounter any problem.
In reply to subhajit maji

Re: Adding new fields to mdl_user

by Anthony Borrow -
Picture of Core developers Picture of Plugin developers Picture of Testers
Subhajit - OK, good luck. I will be traveling most of the day but will try to check in later. Peace - Anthony
In reply to Anthony Borrow

Re: Adding new fields to mdl_user

by Deleted user -
Subhajit, I have done almost this exact same thing, so here are some steps that might helpful.

STEP 1
You will need to add the new fields to the mdl_user table using phpMyAdmin. Once the fields are added to the table, then they will automatically be populated from the external db along with the regular fields, and the info will now be in the Moodle database.

STEP 2
If you also want those fields to actually show up on the Edit Profile page, then you also need to modify the user/editlib.php file to make those fields visible/accessible.

Let me know if you need further assistance with either step.
In reply to Deleted user

Re: Adding new fields to mdl_user

by subhajit maji -

Hello Jeff,

I have done the following things:

  • added new fields to mdl_user
  • changed user/view.php to display the fields
  • changed user/editlib.php to enable editing of field data

Everything working fine. But the External Database plugin is unable to import data to those newly added fields, since in the External DB settings page there is no options to import newly added fields.

Can you please help me? 

In reply to Deleted user

Re: Adding new fields to mdl_user

by subhajit maji -

Hello Jeff, I figured the way out. Edited lib/authlib.php. Now External DB is importing all required fields.

Will contact you for further help.

In reply to subhajit maji

Re: Adding new fields to mdl_user

by umesh chavan -
helo subhajit,

adding new field to mdl-user...i tried doing it in from add 'profile filed' and workd..the filed gets added in the new user creation form...but when i want to take data from excel to all those fileds it dosnt work....it only takes the default fields as usename login password email city course1 course2 ...etc....actually i need more fileds like blood grp, passport no. , emergency contact details, academic details etc....

one more thing from existing users profile i tried taking data into excel that feature is there but it gives all garbage data....it should give all the proper fileds and data out in excel ....

can you put some light on this ?


umesh
In reply to umesh chavan

Re: Adding new fields to mdl_user

by subhajit maji -
Sorry Umesh, I dont have any idea about it. I am using external database for user import.
In reply to Anthony Borrow

Re: Adding new fields to mdl_user

by shree wagh -
hello sir i am shrikant. i have used moodle from last 7 days so i dont know how to edit mdl file also where they r stored so please tell me how can i do it
In reply to subhajit maji

Re: Adding new fields to mdl_user

by Mark Johnson -
Picture of Core developers Picture of Particularly helpful Moodlers Picture of Peer reviewers Picture of Plugin developers

Subhajit,

Not meaning to throw a spanner in the works, but if you upload a flatfile using uploaduser.php, you can import data into User Profile Fields - you just need to prefix the name of the field with "profile_field_" on the first line of your CSV file.  I don't know if that helps in your situation but it might be easier than modifying mdl_user if it does.

Average of ratings: Useful (1)