Uploaded image for project: 'Moodle'
  1. Moodle
  2. MDL-28558

Make requirement of country and city profile fields optional

    Details

    • Type: Improvement
    • Status: Closed
    • Priority: Major
    • Resolution: Fixed
    • Affects Version/s: 2.3
    • Fix Version/s: 2.6
    • Component/s: Administration
    • Labels:
    • Testing Instructions:
      Hide
      1. Log in as admin
      2. Click "Edit profile" and make sure country and city fields are not required.
      3. Edit few values and click "update profile".
      4. Make sure profile gets updated
      5. Create new user (Site administration ► Users ► Accounts ► Add a new user)
      6. Leave city and country as default
      7. Make sure account is created.
      Show
      Log in as admin Click "Edit profile" and make sure country and city fields are not required. Edit few values and click "update profile". Make sure profile gets updated Create new user (Site administration ► Users ► Accounts ► Add a new user) Leave city and country as default Make sure account is created.
    • Workaround:
      Hide

      At present, the city and country fields must be specified when creating a user in Moodle. There is no workaround to this.

      Show
      At present, the city and country fields must be specified when creating a user in Moodle. There is no workaround to this.
    • Affected Branches:
      MOODLE_23_STABLE
    • Fixed Branches:
      MOODLE_26_STABLE
    • Pull Master Branch:
      wip-mdl-28558

      Description

      Petr has suggested as an alternative to MDL-28513 that the country and city fields on a user's profile be made optional with a configuration item to make them a requirement for those sites that require them.

        Gliffy Diagrams

          Issue Links

            Activity

            Hide
            salvetore Michael de Raadt added a comment -

            This is something that we have been discussing lately. It's likely to happen while reviewing profile fields and shifting many of them to become custom profile fields.

            Show
            salvetore Michael de Raadt added a comment - This is something that we have been discussing lately. It's likely to happen while reviewing profile fields and shifting many of them to become custom profile fields.
            Hide
            rex Rex Lorenzo added a comment -

            Why not just remove the requirement check? Here is my post in the forum thread about this topic: http://moodle.org/mod/forum/discuss.php?d=79669#p864203

            Are there really sites that need this information to be required? Is there history as to why this was required in the first place?

            Show
            rex Rex Lorenzo added a comment - Why not just remove the requirement check? Here is my post in the forum thread about this topic: http://moodle.org/mod/forum/discuss.php?d=79669#p864203 Are there really sites that need this information to be required? Is there history as to why this was required in the first place?
            Hide
            mike-hall Mike Hall added a comment -

            Would it be possible to add a default text option for both fields?

            Show
            mike-hall Mike Hall added a comment - Would it be possible to add a default text option for both fields?
            Hide
            rex Rex Lorenzo added a comment -

            You can set defaults by using $CFG->country and $CFG->defaultcity, but those defaults are only used when manually creating user accounts. If a user account was created using Shibboleth, for example, those fields are empty and must be set by the user if they ever edit their profile.

            Show
            rex Rex Lorenzo added a comment - You can set defaults by using $CFG->country and $CFG->defaultcity, but those defaults are only used when manually creating user accounts. If a user account was created using Shibboleth, for example, those fields are empty and must be set by the user if they ever edit their profile.
            Hide
            enboig Lluís Forns added a comment -

            I think the best solution would be to allow admin setting which fields are mandatory.

            Show
            enboig Lluís Forns added a comment - I think the best solution would be to allow admin setting which fields are mandatory.
            Hide
            nyle Nyle Landas added a comment -

            We'd like to make email optional as well. Could you just make it possible to make any non-system required field optional for profile registration. That was we admins can set what we want required and what we don't want required. If we have a user without an email address or one that doesn't want to provide one, we can't easily do this. Editing code makes me nervous because it may impact future versions and I have to edit the code each time I upgrade. Thanks.

            Show
            nyle Nyle Landas added a comment - We'd like to make email optional as well. Could you just make it possible to make any non-system required field optional for profile registration. That was we admins can set what we want required and what we don't want required. If we have a user without an email address or one that doesn't want to provide one, we can't easily do this. Editing code makes me nervous because it may impact future versions and I have to edit the code each time I upgrade. Thanks.
            Hide
            libertymoodle Luis de Vasconcelos added a comment -

            Making email an optional field is a bit complicated because a lot of the Moodle functionality is dependant on email. Examples include the password reset function, course enrolment notifications, etc.

            If email is made a optional field then all those Moodle functions that send email to users could potentially break when you disable email. Code would have to be added to each of those functions to only send emails if the email field has not been made optional. And the some parts of Moodle would have to be radically overhauled, including the password reset function. If users have not been forced to supply an e-mail when they are registered on Moodle then where does Moodle send the password reset e-mails when they forget their passwords?

            So, making email optional isn't something that can be done without big changes to Moodle core.

            Show
            libertymoodle Luis de Vasconcelos added a comment - Making email an optional field is a bit complicated because a lot of the Moodle functionality is dependant on email. Examples include the password reset function, course enrolment notifications, etc. If email is made a optional field then all those Moodle functions that send email to users could potentially break when you disable email. Code would have to be added to each of those functions to only send emails if the email field has not been made optional. And the some parts of Moodle would have to be radically overhauled, including the password reset function. If users have not been forced to supply an e-mail when they are registered on Moodle then where does Moodle send the password reset e-mails when they forget their passwords? So, making email optional isn't something that can be done without big changes to Moodle core.
            Hide
            dobedobedoh Andrew Nicols added a comment -

            Adding the Policy tag to this issue so we can get some input on what should and should not be a required field.

            Show
            dobedobedoh Andrew Nicols added a comment - Adding the Policy tag to this issue so we can get some input on what should and should not be a required field.
            Hide
            nyle Nyle Landas added a comment -

            @Luis de Vasconcelos - I hear you but we haven't required the email field with our 1.9 install and Moodle worked just fine. We had to do this by modifying the PHP code manually. It appears that Moodle is capable of running without the email field being supplied. I of course understand that if it isn't supplied then you can't have the system email that user.

            We use LDAP integration and don't want the students to use Moodle to reset passwords. Our course registrations are manual or via enrolment key.

            What we run into is situations where parents do not want their students to have email accounts but they don't have a problem with them accessing the school run Moodle system. If email isn't an optional field then we have to supply a temporary email account and then delete it to trick the system into thinking it is a legitimate email for the user. Since the student won't be monitoring the account all of the features that you mention are null and void anyway.

            So perhaps Moodle could have an option on a user to not require email for that user as opposed to an override for everyone. However, as I said, we've been running 1.9.x for years now without email being a required field without issues.

            Show
            nyle Nyle Landas added a comment - @Luis de Vasconcelos - I hear you but we haven't required the email field with our 1.9 install and Moodle worked just fine. We had to do this by modifying the PHP code manually. It appears that Moodle is capable of running without the email field being supplied. I of course understand that if it isn't supplied then you can't have the system email that user. We use LDAP integration and don't want the students to use Moodle to reset passwords. Our course registrations are manual or via enrolment key. What we run into is situations where parents do not want their students to have email accounts but they don't have a problem with them accessing the school run Moodle system. If email isn't an optional field then we have to supply a temporary email account and then delete it to trick the system into thinking it is a legitimate email for the user. Since the student won't be monitoring the account all of the features that you mention are null and void anyway. So perhaps Moodle could have an option on a user to not require email for that user as opposed to an override for everyone. However, as I said, we've been running 1.9.x for years now without email being a required field without issues.
            Hide
            libertymoodle Luis de Vasconcelos added a comment -

            What happens when one of those users that you don't have an email for in Moodle tries to reset their password by clicking the "Lost password?" option on the login block? Without a valid email address the students won't get the password reset emails.

            Parents not wanting their students to have email accounts is understandable. Couldn't you use the parents' email instead for these students?

            Show
            libertymoodle Luis de Vasconcelos added a comment - What happens when one of those users that you don't have an email for in Moodle tries to reset their password by clicking the "Lost password?" option on the login block? Without a valid email address the students won't get the password reset emails. Parents not wanting their students to have email accounts is understandable. Couldn't you use the parents' email instead for these students?
            Hide
            dougiamas Martin Dougiamas added a comment -

            My +1 to remove the requirements for country and city. Bigger ideas about admin control can come in a separate issue.

            Show
            dougiamas Martin Dougiamas added a comment - My +1 to remove the requirements for country and city. Bigger ideas about admin control can come in a separate issue.
            Hide
            skodak Petr Skoda added a comment -

            +1 to make the required fields fully configurable. There is also the problem with fully setup users, we might need to relax the user name checks there too.

            Show
            skodak Petr Skoda added a comment - +1 to make the required fields fully configurable. There is also the problem with fully setup users, we might need to relax the user name checks there too.
            Hide
            rajeshtaneja Rajesh Taneja added a comment -

            Hello. I will not be able to work on this issue in the immediate future. In order to create a truer sense of the state of this issue and to allow other developers to have chance to become involved, I am removing myself as the assignee of this issue.

            For more information, see http://docs.moodle.org/dev/Changes_to_issue_assignment

            If you have any information about this issue or a possible fix please post it here

            Show
            rajeshtaneja Rajesh Taneja added a comment - Hello. I will not be able to work on this issue in the immediate future. In order to create a truer sense of the state of this issue and to allow other developers to have chance to become involved, I am removing myself as the assignee of this issue. For more information, see http://docs.moodle.org/dev/Changes_to_issue_assignment If you have any information about this issue or a possible fix please post it here
            Hide
            rajeshtaneja Rajesh Taneja added a comment -

            Removed requirement of city and country, as part of this patch.

            For configuring required fields, we should consider adding them to respective Authentication plugin (Site administration ► Plugins ► Authentication ► Manual accounts).

            While we are adding this feature, we should also consider configuring visibility of user profile fields. I am not opening another issue, as it should be handled as part of MDL-9908

            Show
            rajeshtaneja Rajesh Taneja added a comment - Removed requirement of city and country, as part of this patch. For configuring required fields, we should consider adding them to respective Authentication plugin (Site administration ► Plugins ► Authentication ► Manual accounts). While we are adding this feature, we should also consider configuring visibility of user profile fields. I am not opening another issue, as it should be handled as part of MDL-9908
            Hide
            abgreeve Adrian Greeve added a comment -

            Hello Rajesh,

            I had a look at the code and I see no problems. Things that I considered when peer reviewing:

            • I checked the web services to make sure changes are not required there (They are not. The parameters are already set to optional.).
            • Possible changes to the database structure (Also no changes required here either).

            Thanks.

            Show
            abgreeve Adrian Greeve added a comment - Hello Rajesh, I had a look at the code and I see no problems. Things that I considered when peer reviewing: I checked the web services to make sure changes are not required there (They are not. The parameters are already set to optional.). Possible changes to the database structure (Also no changes required here either). Thanks.
            Hide
            rajeshtaneja Rajesh Taneja added a comment -

            Thanks Adrian,

            Pushing it for integration.

            Show
            rajeshtaneja Rajesh Taneja added a comment - Thanks Adrian, Pushing it for integration.
            Hide
            stronk7 Eloy Lafuente (stronk7) added a comment -

            Clarification required: Is this aiming to 2.6 only, or are intentions to put it also in 25_STABLE?

            Show
            stronk7 Eloy Lafuente (stronk7) added a comment - Clarification required: Is this aiming to 2.6 only, or are intentions to put it also in 25_STABLE?
            Hide
            rajeshtaneja Rajesh Taneja added a comment -

            This being improvement, is candidate for master only. Not sure if Martin wants this in 2.5

            Show
            rajeshtaneja Rajesh Taneja added a comment - This being improvement, is candidate for master only. Not sure if Martin wants this in 2.5
            Hide
            dougiamas Martin Dougiamas added a comment -

            2.6 only for now I think. Once it's cooked for a while, and if there's any demand for it, it could be backported to 2.5.1

            Show
            dougiamas Martin Dougiamas added a comment - 2.6 only for now I think. Once it's cooked for a while, and if there's any demand for it, it could be backported to 2.5.1
            Hide
            poltawski Dan Poltawski added a comment -

            Adding integration_held, as this is a master only new feature we will only add to 2.6 once the on-sync period ends.

            Show
            poltawski Dan Poltawski added a comment - Adding integration_held, as this is a master only new feature we will only add to 2.6 once the on-sync period ends.
            Hide
            nyle Nyle Landas added a comment - - edited

            @Luis de Vasconcelos - We have cases where the parents don't have email accounts as well. In some cases Mennonites and others just rural. Our x.500 directory supports password retrieval, we don't need the Moodle server to offer this functionality.

            So perhaps, make email optional and allow turning off the password email function when you do that. Are there other issues with making email optional?

            -Should I open another issue even through this one deals with making profile fields options?

            Show
            nyle Nyle Landas added a comment - - edited @Luis de Vasconcelos - We have cases where the parents don't have email accounts as well. In some cases Mennonites and others just rural. Our x.500 directory supports password retrieval, we don't need the Moodle server to offer this functionality. So perhaps, make email optional and allow turning off the password email function when you do that. Are there other issues with making email optional? -Should I open another issue even through this one deals with making profile fields options?
            Hide
            samhemelryk Sam Hemelryk added a comment -

            This has been integrated now. Hopefully MDL-9908 gets looked at soon - Raj is it somewhere on the backend teams list?

            Nyle - please open another issue and link to this issue marking them related.

            Show
            samhemelryk Sam Hemelryk added a comment - This has been integrated now. Hopefully MDL-9908 gets looked at soon - Raj is it somewhere on the backend teams list? Nyle - please open another issue and link to this issue marking them related.
            Hide
            rajeshtaneja Rajesh Taneja added a comment -

            No Sam,

            MDL-9908 was not on list, I've put it on Backend backlog.
            It will be nice to have this in 2.6.

            Show
            rajeshtaneja Rajesh Taneja added a comment - No Sam, MDL-9908 was not on list, I've put it on Backend backlog. It will be nice to have this in 2.6.
            Hide
            skodak Petr Skoda added a comment -

            works as described, I guess this will make Eloy sad because he used this feature to get IP mapping data from this.

            There is one related problem, the country and city are set automatically from the template user (admin) when uploading user, maybe it should be removed from there too. Please create a new issue for that if necessary.

            Show
            skodak Petr Skoda added a comment - works as described, I guess this will make Eloy sad because he used this feature to get IP mapping data from this. There is one related problem, the country and city are set automatically from the template user (admin) when uploading user, maybe it should be removed from there too. Please create a new issue for that if necessary.
            Hide
            marina Marina Glancy added a comment -

            Thanks for your awesome work! This has now become a part of Moodle.

            Closing as fixed!

            Show
            marina Marina Glancy added a comment - Thanks for your awesome work! This has now become a part of Moodle. Closing as fixed!
            Hide
            marycooch Mary Cooch added a comment -

            Just noting I made a brief mention of this in http://docs.moodle.org/26/en/Update_profile so have removed the docs_required label.

            Show
            marycooch Mary Cooch added a comment - Just noting I made a brief mention of this in http://docs.moodle.org/26/en/Update_profile so have removed the docs_required label.
            Hide
            michael-milette Michael Milette added a comment -

            Just migrated from Moodle 2.5 to 2.6 for a site with International participation. I need both Country and City to be required fields as they were in Moodle 2.5. How can I re-enable this requirement? I would rather not have to customize core code as I don't want to have to maintain the changes when we upgrade to Moodle 2.7.x, 2.8.x, etc.

            On a side note, ideally each of the Optional Moodle user profile fields should have options to control whether they are visible AND/OR required.

            Best regards,

            Michael Milette

            Show
            michael-milette Michael Milette added a comment - Just migrated from Moodle 2.5 to 2.6 for a site with International participation. I need both Country and City to be required fields as they were in Moodle 2.5. How can I re-enable this requirement? I would rather not have to customize core code as I don't want to have to maintain the changes when we upgrade to Moodle 2.7.x, 2.8.x, etc. On a side note, ideally each of the Optional Moodle user profile fields should have options to control whether they are visible AND/OR required. Best regards, Michael Milette
            Hide
            harrysmith Just H added a comment -

            Michael, the answer is at https://moodle.org/mod/forum/discuss.php?d=275507#p1184229 if you are still looking for a fix.

            Show
            harrysmith Just H added a comment - Michael, the answer is at https://moodle.org/mod/forum/discuss.php?d=275507#p1184229 if you are still looking for a fix.
            Hide
            michael-milette Michael Milette added a comment - - edited

            Thank you Harry for pointing me towards David Mudrák's post. I appreciate you trying to help. I had already thought of reversing the patch but then I would have to keep remembering to patch Moodle each time I upgrade forever.

            What I am looking for is a supported core solution that allows me to do this. As I mentioned in my post, my preference would be to have the flexibility of displaying/hiding each of the optional fields and making them mandatory or optional. I can do this by using Custom profile fields but the fields built-into Moodle lack that important feature.

            Best regards,

            Michael

            Show
            michael-milette Michael Milette added a comment - - edited Thank you Harry for pointing me towards David Mudrák's post. I appreciate you trying to help. I had already thought of reversing the patch but then I would have to keep remembering to patch Moodle each time I upgrade forever. What I am looking for is a supported core solution that allows me to do this. As I mentioned in my post, my preference would be to have the flexibility of displaying/hiding each of the optional fields and making them mandatory or optional. I can do this by using Custom profile fields but the fields built-into Moodle lack that important feature. Best regards, Michael

              People

              • Votes:
                11 Vote for this issue
                Watchers:
                18 Start watching this issue

                Dates

                • Created:
                  Updated:
                  Resolved:
                  Fix Release Date:
                  18/Nov/13