Moodle
  1. Moodle
  2. MDL-28558

Make requirement of country and city profile fields optional

    Details

    • Type: Improvement Improvement
    • Status: Closed
    • Priority: Major 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

            Andrew Nicols created issue -
            Hide
            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
            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.
            Michael de Raadt made changes -
            Field Original Value New Value
            Fix Version/s DEV backlog [ 10464 ]
            Priority Minor [ 4 ] Major [ 3 ]
            Labels triaged
            Michael de Raadt made changes -
            Link This issue will be resolved by MDL-28452 [ MDL-28452 ]
            Michael de Raadt made changes -
            Link This issue has been marked as being related by MDL-32445 [ MDL-32445 ]
            Hide
            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 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 added a comment -

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

            Show
            Mike Hall added a comment - Would it be possible to add a default text option for both fields?
            Hide
            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 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.
            Luis de Vasconcelos made changes -
            Link This issue has a non-specific relationship to MDL-9908 [ MDL-9908 ]
            Hide
            Lluís Forns added a comment -

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

            Show
            Lluís Forns added a comment - I think the best solution would be to allow admin setting which fields are mandatory.
            Hide
            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 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
            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
            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.
            Andrew Nicols made changes -
            Component/s Policy [ 12733 ]
            Hide
            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
            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 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 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
            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
            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
            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
            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.
            Martin Dougiamas made changes -
            Component/s Policy [ 12733 ]
            Hide
            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
            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
            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
            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
            Rajesh Taneja made changes -
            Assignee Rajesh Taneja [ rajeshtaneja ]
            Hide
            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
            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
            Rajesh Taneja made changes -
            Pull Master Diff URL https://github.com/rajeshtaneja/moodle/compare/master...wip-mdl-28558
            Pull Master Branch wip-mdl-28558
            Testing Instructions # 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.
            Pull from Repository git://github.com/rajeshtaneja/moodle.git
            Assignee Rajesh Taneja [ rajeshtaneja ]
            Rajesh Taneja made changes -
            Status Open [ 1 ] Waiting for peer review [ 10012 ]
            Adrian Greeve made changes -
            Original Estimate 0 minutes [ 0 ]
            Remaining Estimate 0 minutes [ 0 ]
            Status Waiting for peer review [ 10012 ] Peer review in progress [ 10013 ]
            Peer reviewer abgreeve
            Hide
            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
            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.
            Adrian Greeve made changes -
            Status Peer review in progress [ 10013 ] Development in progress [ 3 ]
            Hide
            Rajesh Taneja added a comment -

            Thanks Adrian,

            Pushing it for integration.

            Show
            Rajesh Taneja added a comment - Thanks Adrian, Pushing it for integration.
            Rajesh Taneja made changes -
            Status Development in progress [ 3 ] Waiting for integration review [ 10010 ]
            Eloy Lafuente (stronk7) made changes -
            Currently in integration Yes [ 10041 ]
            Hide
            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
            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
            Rajesh Taneja added a comment -

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

            Show
            Rajesh Taneja added a comment - This being improvement, is candidate for master only. Not sure if Martin wants this in 2.5
            Hide
            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
            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
            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
            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.
            Dan Poltawski made changes -
            Labels triaged integration_held triaged
            Dan Poltawski made changes -
            Currently in integration Yes [ 10041 ]
            Hide
            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 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?
            Sam Hemelryk made changes -
            Currently in integration Yes [ 10041 ]
            Sam Hemelryk made changes -
            Labels integration_held triaged triaged
            Sam Hemelryk made changes -
            Status Waiting for integration review [ 10010 ] Integration review in progress [ 10004 ]
            Integrator samhemelryk
            Hide
            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
            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.
            Sam Hemelryk made changes -
            Status Integration review in progress [ 10004 ] Waiting for testing [ 10005 ]
            Fix Version/s 2.6 [ 12579 ]
            Fix Version/s DEV backlog [ 10464 ]
            Hide
            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
            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.
            Petr Skoda made changes -
            Status Waiting for testing [ 10005 ] Testing in progress [ 10011 ]
            Tester skodak
            Hide
            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
            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.
            Petr Skoda made changes -
            Status Testing in progress [ 10011 ] Tested [ 10006 ]
            Nyle Landas made changes -
            Link This issue has a non-specific relationship to MDL-40134 [ MDL-40134 ]
            Hide
            Marina Glancy added a comment -

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

            Closing as fixed!

            Show
            Marina Glancy added a comment - Thanks for your awesome work! This has now become a part of Moodle. Closing as fixed!
            Marina Glancy made changes -
            Status Tested [ 10006 ] Closed [ 6 ]
            Resolution Fixed [ 1 ]
            Currently in integration Yes [ 10041 ]
            Integration date 14/Jun/13
            Helen Foster made changes -
            Labels triaged docs_required triaged
            Petr Skoda made changes -
            Link This issue caused a regression MDL-40796 [ MDL-40796 ]
            Rajesh Taneja made changes -
            Link This issue is duplicated by MDL-40688 [ MDL-40688 ]
            Michael de Raadt made changes -
            Link This issue caused a regression MDL-43488 [ MDL-43488 ]
            Hide
            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
            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.
            Mary Cooch made changes -
            Labels docs_required triaged triaged
            Hide
            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 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
            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
            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 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 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: