Upload users with custom profile fields

Upload users with custom profile fields

by Lakshmi Iyer -
Number of replies: 10

How do I upload users with the custom user profile field?? Is there any syntax to be followed. I tried profile_field_****** where ****** is custom field name. But this doesnot work.

Version 1.9

Average of ratings: -
In reply to Lakshmi Iyer

Re: Upload users with custom profile fields

by Anthony Borrow -
Picture of Core developers Picture of Plugin developers Picture of Testers
Do you have the latest version of 1.9? MDL-11996 has done some work to improve importing and this included being able to import custom field. I have not yet tried it to see how it works but I wanted to make sure you are using the latest code. Peace - Anthony
In reply to Lakshmi Iyer

Re: Upload users with custom profile fields

by Anthony Borrow -
Picture of Core developers Picture of Plugin developers Picture of Testers
I tried too and did not initially have success. I was told that the field "profile_field_birthday" is not a valid field name so I tried the shortname and that worked. I have modified the help file so that it clarifies that the "real name" is the unique short name. If you use the short name, are you able to get it to work? Peace - Anthony
In reply to Anthony Borrow

Re: Upload users with custom profile fields

by Lakshmi Iyer -
Hi Anthony,

I tried with the latest version 1.9. After a long time, I figured out that there is a small bug. You will have to give the custom profile field name in small case letters. Because in the code, the left hand string which is not converted to lowercase is compared with the right hand string which is always converted to lower case before comparison. so we have to make sure that the shortname for the custom profile field is given in lower case. Then the comparison goes through and it works.

Regards,
Lakshmi
Average of ratings: Useful (1)
In reply to Lakshmi Iyer

Re: Upload users with custom profile fields

by Anthony Borrow -
Picture of Core developers Picture of Plugin developers Picture of Testers
Lakshmi - Go ahead and file an issue in the tracker and point out where it was that you saw the comparison problem. Since the field names have to be unique and are not case sensitive then both comparisons should cast to lowercase. I noticed that if I changed the casting of the field names that I was able to get around checking of the field; however, the data was not imported which indicated to me that somewhere else the comparisons need to be cast correctly. Peace - Anthony
In reply to Anthony Borrow

Re: Upload users with custom profile fields

by Aye-mon Myo -

Hi,

I just upgraded our server to 1.9 from 1.8 and it seems like I'm still having the problem in uploading users with custom profile files. It still gives me the message that the custom field name is not a valid field. Any help would be great. Thanks a lot.

Aye-Mon

In reply to Aye-mon Myo

Re: Upload users with custom profile fields

by Aye-mon Myo -

Okay, it's working now. I didn't know I have to put the prefix "profile_field_" for the custom field names. But, it only works with Text Inputs. It didn't work with menu of choices. Any help would be great. Thanks.

Aye-Mon

In reply to Aye-mon Myo

Re: Upload users with custom profile fields

by Anthony Borrow -
Picture of Core developers Picture of Plugin developers Picture of Testers
Aye-Mon - I'm working on a few other projects at the moment but I will try to come back and test this. Might you file an issue in the tracker and let me know the number. It would also help if you uploaded a sample text file and describe your situation in as much detail. Then I will go in and try to re-create the problem and evaluate what is happening (unless someone else beats me to it - which is not unlikely). Peace - Anthony
In reply to Anthony Borrow

Re: Upload users with custom profile fields

by Aye-mon Myo -

Actually I figured out something else. It does not work with any of the fields which has choices including the default ones in Moodle. e.g. maildisplay.

Yes, I will report this in the tracker with the steps to reproduce and let you know the number.

Thanks,

Aye-Mon

In reply to Aye-mon Myo

Re: Upload users with custom profile fields

by James Lloyd -

Hi folks,

I have also been dealing with this.  Knowing how the dropdown list field works in HTML I experimented and realized that when importing to a custom profile field which was created as a menu of choices, you CANNOT import the VALUES of the choices, but instead the index number of the choice.

So in my case we created a profile_field_gender with 3 choices M, F, and - (for us the hyphen means, 'prefer not to reveal').

So, in the .csv import file under the heading for that field, you must enter a 0 to select the first option (M), a 1 for the second option (F) or a 2 for the third option (-).

Said another way, when building your .csv file, you will need to know that:

0 = "M"
1 = "F"
2 = "-"

I searched the Moodle docs and could not find any reference to this so maybe it can be added to the issue tracker (still haven't spent time learning to use the tracker myself - I really need to do that)!

-james

Average of ratings: Useful (2)
In reply to James Lloyd

Re: Upload users with custom profile fields

by Lisa Pedicini -
I've been struggling with a bulk upload which generates only the "profile_field_affiliation" is not a valid field name result. Was thrilled to find your suggestion that using correlating numbers for my year of graduation drop down entries might be the trick, but still no luck.

Am using the "short name." Am using 1.9. My headers are:

username password firstname lastname email profile_field_affiliation

Am close to giving up and uploading without the custom field and just asking users to set that themselves. Seems unfortunate. If anyone sees something obvious --or even not so obvious-- that I'm doing wrong, I'd be grateful for pointers.

Thank you