2.5.1 I want to remove the registration fields city and country and no one can tell me how.

2.5.1 I want to remove the registration fields city and country and no one can tell me how.

by Wendi Daniels -
Number of replies: 11

I have tried all suggestions, and nothing seems to work. I am really pissed off. I have been at this for days. What am I doing wrong, and how the HELL do I get those fields off of the damned sign up form?!?!?

This is what I have done so far:

********************************************************************

 in   public_html_/user/editlib.php   I did this:

 

 /* $mform->addElement('text', 'city', get_string('city'), 'maxlength="120" size="21"'); */
    /* $mform->setType('city', PARAM_MULTILANG); */
    /* $mform->addRule('city', $strrequired, 'required', null, 'client'); */
    /* if (!empty($CFG->defaultcity)) {
        $mform->setDefault('city', $CFG->defaultcity); */
   /* } */

 ****************************************************************************************

 

In  public_html_/user/editadvanced_form.php  I did this:

 

   /* if (!$user or $user->email !== $usernew->email) {
            if (!validate_email($usernew->email)) {
                $err['email'] = get_string('invalidemail'); */
           /* } else if ($DB->record_exists('user', array('email'=>$usernew->email, 'mnethostid'=>$CFG->mnet_localhost_id))) {
                $err['email'] = get_string('emailexists'); */
           */  } */
      */  } */

 

****************************************************************************

In PHPMyAdmin I set city and country both to "Null", and then dropped city altoether to see it that would do anything, as nothing works. Others are saying that this plan works just like a charm, and I can't get any change at all. I clear the cache and nothing happens. How do I finally fix this?! I don't want to be working on this for a few more days just to get those #$%^$ing fields removed!

 

Please help,

Wendi

 

 

 

 

 

 

Average of ratings: -
In reply to Wendi Daniels

Re: 2.5.1 I want to remove the registration fields city and country and no one can tell me how.

by G. M. -

Hi Wendi,

I cannot test the advice given to you, but...

1. Regarding the editlib.php file, you missed blocking the country part. You can comment out both, the city and country sections, like so:

/*
$mform->addElement('text', 'city', get_string('city'), 'maxlength="120" size="21"'); $mform->setType('city', PARAM_TEXT); $mform->addRule('city', $strrequired, 'required', null, 'client'); if (!empty($CFG->defaultcity)) { $mform->setDefault('city', $CFG->defaultcity); }

$choices = get_string_manager()->get_list_of_countries(); $choices= array(''=>get_string('selectacountry').'...') + $choices; $mform->addElement('select', 'country', get_string('selectacountry'), $choices); $mform->addRule('country', $strrequired, 'required', null, 'client'); if (!empty($CFG->country)) { $mform->setDefault('country', $CFG->country); }
*/

2. About the editadvanced_form.php file, the last two lines didn't start with a slash star but with a star slash. You may block that section like this:

/*
if (!$user or $user->email !== $usernew->email) { if (!validate_email($usernew->email)) { $err['email'] = get_string('invalidemail'); } else if ($DB->record_exists('user', array('email'=>$usernew->email, 'mnethostid'=>$CFG->mnet_localhost_id))) { $err['email'] = get_string('emailexists'); } }
*/

3. About the user table, I already answered in the original thread.

4. Besides clearing the cache, I would restart both, the Apache and the MySQL servers.

Cheers!

In reply to G. M.

Re: 2.5.1 I want to remove the registration fields city and country and no one can tell me how.

by Wendi Daniels -

Thank you, Guillermo. I have done everything as suggested to no avail, but there are a few discrepencies:

 

1) Do I need to be in "Public_html" (with the globe sign), or in "Public_html_" (without the globe sign)?

2) I commented out every line, and now just the sections are commented out. Thank you.   smile

3) I commented out only city as I was trying to figure out the missing link.

4) One Moodler suggested commenting out this code:

    if (!$user or $user->email !== $usernew->email) {
        if (!validate_email($usernew->email)) {
            $err['email'] = get_string('invalidemail');
    } else if (record_exists('user', 'email', $usernew->email, 'mnethostid', $CFG->mnet_localhost_id)) {
        $err['email'] = get_string('emailexists');
        }

 

but it does not appear to exist. I did find this one, but commenting it out did not help.

    if (!$user or $user->email !== $usernew->email) {
        if (!validate_email($usernew->email)) {
            $err['email'] = get_string('invalidemail');
    } else if ($DB->record_exists('user', array('email'=>$usernew->email,
'mnethostid'=>$CFG->mnet_localhost_id))) {
        $err['email'] = get_string('emailexists');

 

 

I cannot tell you how much I appreciate your help. This is so frustrating when everyone seems to say it is so easy, and I have done everything advised, and nothing has changed. Surely there is one simple thing missing. any ideas?   :/

In reply to Wendi Daniels

Re: 2.5.1 I want to remove the registration fields city and country and no one can tell me how.

by G. M. -

Hi Wendi,

Should you be at Public_html or at Public_html_? Ah, now we're getting to something!

I'd bet that there lies the reason for your problem of not seeing any result from the changes you've been making. I'd say you should be working on the files and directories under Public_html. The other folder (Public_html_) was probably created as a backup of Public_html, and so, if you are working under any files and directories below it, then you are not working at the right place.

I don't know the structure of your server, but take into account that the usual and standard name of the Document Root Directory is usually public_html (all lower case), and not Public_html; it seems strange to me that your folder is named with a capital letter.

Cheers! smile

In reply to G. M.

Re: 2.5.1 I want to remove the registration fields city and country and no one can tell me how.

by Wendi Daniels -

That was indeed part of the problem. Thank you so much, Guillermo! Also, I found I needed to comment out the city and country coding in login/signup.php. You were so helpful, and I am quite grateful! Thank you!

 

In reply to Wendi Daniels

Re: 2.5.1 I want to remove the registration fields city and country and no one can tell me how.

by G. M. -

You're welcome Wendi!

Yes, sometimes problems are not where one thinks they are, and that's when one has to start looking a bit further. This is also why I recommended you to seek help from a programmer, as she or he would have detected the problem once having access to your server. Anyway, you finally managed to accomplish what you initially wanted, so... congratulations Yes

In reply to Wendi Daniels

Re: 2.5.1 I want to remove the registration fields city and country and no one can tell me how.

by Doug Loomer -

Hi Wendy,

Sounds like you have already solved this by adjusting the php code, but I'm wondering (if all you want is for the fields not to display) if it wouldn't be better to just set their display value to none using CSS. When you hack the Moodle php core, your code will probably be broken by every update.  Just wondering.

All the best.

In reply to Doug Loomer

Re: 2.5.1 I want to remove the registration fields city and country and no one can tell me how.

by G. M. -

Hi Doug,

Sounds like that could be an option: set their default values at the location settings and then make them invisible through CSS; of course, the problem would then be to assign those fields a new selector thoughtful

In reply to G. M.

Re: 2.5.1 I want to remove the registration fields city and country and no one can tell me how.

by Wendi Daniels -

Ah...something else to understand. I will look up CSS and find out what that is when I get home from work. Probably a valuable insight. Thank you.  smile

In reply to Wendi Daniels

Re: 2.5.1 I want to remove the registration fields city and country and no one can tell me how.

by Barbara Taylor -

If using self-registration then:

  • Site administration
  • /  Plugins
  • /  Authentication
  • /  Email-based self-registration

Switch all of the fields you don't want people to enter data in to Locked and Save changes.

In reply to Barbara Taylor

Re: 2.5.1 I want to remove the registration fields city and country and no one can tell me how.

by Wendi Daniels -

Barbara, I thought "locked" just meant that once they enter a value, they cannot change it.

In reply to Wendi Daniels

Re: 2.5.1 I want to remove the registration fields city and country and no one can tell me how.

by Doug Loomer -

Hi Wendi,

CSS (cascading style sheets) are used to style web pages.  In Moodle, style sheets are used to create different themes.  It is relatively straight forward to add a custom style sheet which will load after the existing style sheets for a theme load, thereby adding custom styling to your theme without altering the underlying stylesheet code or core Moodle PHP code.

One of the things you can do with CSS is tell html elements to NOT display.  CSS is probably the easiest portion of the web development tool kit to learn, and there are some great tutorials and information at the W3Schools website. 

http://www.w3schools.com/

It's pretty straight forward, but let me know if you have questions.

All the best,

Doug