General developer forum

How to remove user's field when creating or editing users' profile

 
Picture of Worawat Lawanont
How to remove user's field when creating or editing users' profile
 

Hi all,

 

I'm trying to remove unnecessary field from creating user page and editing profile page, most of them are in optional section, such as, AIM, MSN.,

 

Are there anyway to do so (including editing the code)?

I need a guideline.

 

Thanks a lot in advance smile

 
Average of ratings: -
Picture of Shashikant Vaishnav
Re: How to remove user's field when creating or editing users' profile
 

Hello Worawat,

 

You may override useredit_shared_definition() method in /user/editlib.php file. Or either you may directly comment the header containing Optional fields.

    /// Moodle optional fields
  //  $mform->addElement('header', 'moodle_optional', get_string('optional', 'form'));

 

Good luck,

Shashikant

 
Average of ratings: Useful (1)
Picture of Julio Fernández Avancini
Re: How to remove user's field when creating or editing users' profile
 

Hi, it is possible to do this without modify the source? Just the theme or something like that? (in Wordpress functions.php) So when it upgrades I won't loose anything. And how to hide Additional names? I really don't understand about this.

Thanks in advance.

 
Average of ratings: -
Picture of Jon Bolton
Re: How to remove user's field when creating or editing users' profile
Particularly helpful MoodlersTesters

In your custom CSS, add...

div#fitem_id_icq {display: none;}

div#fitem_id_skype {display: none;}

div#fitem_id_aim {display: none;}

div#fitem_id_yahoo {display: none;}

div#fitem_id_msn {display: none;}

fieldset#id_moodle_additional_names {display: none;}

 
Average of ratings: Useful (10)
Picture of Julio Fernández Avancini
Re: How to remove user's field when creating or editing users' profile
 

Thanks you!

 
Average of ratings: -
Picture of DeLoy Wilkins
Re: How to remove user's field when creating or editing users' profile
 

Thanks John !!

 
Average of ratings: -
Picture of Debbie Kay
Re: How to remove user's field when creating or editing users' profile
 

Many thanks Jon!

 
Average of ratings: -
Picture of Sidd Lep
Odgovor: Re: How to remove user's field when creating or editing users' profile
 

Thank you, Jon.

This worked for many of optional fields, except for web page, ID number, phone and mobile phone. 

This is the code I wrote:


div#fitem_id_web_page {display: none;}

div#fitem_id_id_number {display: none;}

div#fitem_id_phone {display: none;}

div#fitem_id_phone_number {display: none;}


So, is this code correct or I made some mistakes.

And, is it possible to hide all "optional" section by one line of code, instead of writing the line for each of the optional fields.


Thank you.



 
Average of ratings: Useful (1)
Picture of Jon Bolton
Re: Odgovor: Re: How to remove user's field when creating or editing users' profile
Particularly helpful MoodlersTesters

Should be:

div#fitem_id_url {display: none;}
div#fitem_id_idnumber {display: none;}
div#fitem_id_phone1 {display: none;}
div#fitem_id_phone2 {display: none;}


To hide ALL optional fields:

fieldset#id_moodle_optional {display: none;}


 
Average of ratings: Useful (6)
Picture of Łukasz Sanokowski
Odp: Re: Odgovor: Re: How to remove user's field when creating or editing users' profile
Plugin developers

Thank you Jon, it's awesome solution in its simplicity. What is the code to hide "City/town" and "Timezone" fields on the same page?

 
Average of ratings: -
Picture of Jon Bolton
Re: Odp: Re: Odgovor: Re: How to remove user's field when creating or editing users' profile
Particularly helpful MoodlersTesters
div#fitem_id_city {display: none;}
div#fitem_id_timezone  {display: none;}
 
Average of ratings: Useful (4)
Picture of ray cheng
回應: Re: Odp: Re: Odgovor: Re: How to remove user's field when creating or editing users' profile
 

Hi Jon,

Can you tell how to hide "User Picture" section?

Also in my moodle version 3.3, 

div#fitem_id_timezone  {display: none;}
cannot hide the time zone field.

Thanks for your time
Ray

 
Average of ratings: -
Picture of Phuong Hoang
Re: 回應: Re: Odp: Re: Odgovor: Re: How to remove user's field when creating or editing users' profile
Particularly helpful Moodlers

Hi Ray,

To hide User picture, try this

fieldset#id_moodle_picture {display: none;}

To hide Timezone

div#fitem_id_timezone {display: none;}

- It works. Check your space (single space)

If necessary, Purge all caches


 
Average of ratings: -
Picture of Sam Suresh
Re: Odgovor: Re: How to remove user's field when creating or editing users' profile
 

Hi

In version 3.4, the class is only "form-group row fitem" for all fields under Optional. Im trying to hide ICQ, Skype etc. But it seems not possible to hide the label but only possible to hide the input box. 

nth-child() may work but its not a reliable way. 

Any other way to hide ICQ, MSN in version 3.4? 

(Completely hiding optional fields is not a good idea too. Because custom fields are not working everywhere. For example user list etc). 

 
Average of ratings: -
Picture of Michael Milette
Re: Odgovor: Re: How to remove user's field when creating or editing users' profile
Core developersParticularly helpful MoodlersPlugin developers

To hide some of the optional profile fields, you can do something like this in CSS:

#fitem_id_url,
#fitem_id_icq,
#fitem_id_skype,
#fitem_id_aim,
#fitem_id_yahoo,
#fitem_id_msn,
#fitem_id_idnumber {
    display:none;
}

This works in all versions of Moodle that I have used since Moodle 2.5 to 3.4. I just confirmed it in Moodle 3.4 using the Boost and Clean themes.

Hope you find this useful.

Best regards,

Michael

 
Average of ratings: -
Picture of Terry Aulenbach
Re: Odgovor: Re: How to remove user's field when creating or editing users' profile
 

Where exactly can you add these in the Boost theme? It doesn't have a custom css field. Only Raw initial SCSS and Raw SCSS. Neither location seems to change anything when the page loads, even after clearing the theme cache.

 
Average of ratings: -
Picture of Sam Mudle
Re: Odgovor: Re: How to remove user's field when creating or editing users' profile
Particularly helpful Moodlers
Confirmed working in Moodle 3.5.1
 
Average of ratings: -
Picture of Terry Aulenbach
Re: Odgovor: Re: How to remove user's field when creating or editing users' profile
 

Could you please tell me what it is that is confirmed working in 3.5.1?

 
Average of ratings: -
Picture of Michael Milette
Re: Odgovor: Re: How to remove user's field when creating or editing users' profile
Core developersParticularly helpful MoodlersPlugin developers

Hiding some of the optional the fields in the profile edit page is pretty straight forward. The bigger challenge is to hide these fields from users when one views either their own or someone else's profile.

Depending on your requirements, you may also want these fields to be visible when managers or administrators are editing a user's profile.

Just a couple of things to keep in mind.

Best regards,

Michael

 
Average of ratings: -
Picture of Chardelle Busch
Re: Odgovor: Re: How to remove user's field when creating or editing users' profile
Core developers

Hello,

I typically "hide" several things on the profile page using css.

The timezone is a tricky one, if you are wanting to hide it using #fitem_id_timezone  {display: none;} and it isn't working, you need to go to Administration>Location>Location Settings and for Force Timezone, you must set it to:  Users can choose their own timezone (however, they obviously won't be able to because it is hidden). 

If that setting is set to force a timezone, then that field becomes uneditable and no longer includes the fitem timezone class notation. 


 
Average of ratings: -
Picture of Ruchi Dixit
Re: Odgovor: Re: How to remove user's field when creating or editing users' profile
 

Thanks

 
Average of ratings: -
Picture of John Graham
Re: How to remove user's field when creating or editing users' profile
 

Hi Jon,

I cannot get this to work, when I use your code div#fitem_id_skype {display: none;} it still displays the field and label.

if I add this to my CSS  #id_skype {display: none;} it will remove the field but not the label? 

Any Ideas?

I am using Moodle version 3.3.5+

Thanks

John

 
Average of ratings: -
Picture of Chardelle Busch
Re: How to remove user's field when creating or editing users' profile
Core developers
You might try just using #fitem_id_skype without div.

Note that you can also hide an entire section, for example, I hide the entire section where skype is with:

#id_moodle_optional {display: none;}
 
Average of ratings: Useful (1)
Picture of John Graham
Re: How to remove user's field when creating or editing users' profile
 

Hi Chardelle,


I tried that without the div and still doesn't work. I am using the Acadami theme if that helps?

I have used the code you have mentioned to hide Interests etc but I want to use some of the fields in the optional section so would not want to hide everything.

 
Average of ratings: -
Picture of Chardelle Busch
Re: How to remove user's field when creating or editing users' profile
Core developers

Hmmm... Sorry, not sure what to tell you.  I just did a test and #fitem_id_skype  {display: none;} works for me.  Make sure you clear your theme cache after making the change (Appearance>Themes>Theme selector)

I can't imagine that a theme would alter the form ids but it might have some parent css that is.  If that is the case, you can try adding  !important to the css to override it, #fitem_id_skype  {display: none !important;}

You might also try developer tools to check, e.g. in FireFox right click over the Skype label and click on Inspect Element or in Chrome, right click and choose Inspect.  In the Inspector that opens up you should see that css.  That div starts with this:

<div id="fitem_id_skype" class="fitem fitem_ftext ">.  So when you put #fitem_id_skype in your css file, the # indicates it is a div id (not div class) with that id name.

 
Average of ratings: -
Picture of John Graham
Re: How to remove user's field when creating or editing users' profile
 

I cleared the theme cache and purge all caches. Still didn't work. This was a few days ago so was going to have a look at this again. I normally make changes in the Moodle Core but wanted to do everything in the CSS this time around. I will have another look but for a short term solution I have managed to do this in the core. I went to the user folder and edited the file editlib.php. The optional fields are from line 383 and I commented out the code. Thought I would put this in here in case anyone is having the same issue as me.

Thanks for your help.

 
Average of ratings: -
Picture of William Bergman
Re: How to remove user's field when creating or editing users' profile
 

Hello,


I would like to create a certificate that will display individual "code" per student.  I had planned to use the ICQ field and hide the field.  After hiding the field it is also hidden from the certificate.  Is there a way to remove the field from the "Edit Profile" page and leave it visible to the certificate plugin?  Moodle 3.3.1 using Custom Certificate Plugin 

Custom certificate
mod_customcert
3.3 release (Build: 2017050508)
2017050508
This is quite urgent, any assistance would be greatly appreciated.



 
Average of ratings: -
Picture of Michael Milette
Re: How to remove user's field when creating or editing users' profile
Core developersParticularly helpful MoodlersPlugin developers

You can remove the user's fields from just the profile edit page by specifying #page-user-edit which is a body tag ID. Example:

#page-user-edit #fitem_id_url,
#page-user-edit #fitem_id_icq,
#page-user-edit #fitem_id_skype,
#page-user-edit #fitem_id_aim,
#page-user-edit #fitem_id_yahoo,
#page-user-edit #fitem_id_msn,
#page-user-edit #fitem_id_idnumber {
    display:none;
}

 
Average of ratings: -
Picture of Yoel Gutierrez
Re: How to remove user's field when creating or editing users' profile
 

Hello, 


I am implementing moodle in my work, I am really new in this, can you tell me where is this file located to be edited. So I can make the edits.


thanks

 
Average of ratings: -
Picture of Chardelle Busch
Re: How to remove user's field when creating or editing users' profile
Core developers

Hi Yoel,

We are talking here about hiding things using css in your theme's stylesheet.  This will be put into your site themes css file which will be located under your theme folder, for example theme/yourtheme/style/custom.css.  Your theme may also have a custom css setting where you can add custom css, for example under Appearance>Themes>Your theme name

 
Average of ratings: -
Picture of Ralf Hilgenstock
Re: How to remove user's field when creating or editing users' profile
Core developersParticularly helpful MoodlersTranslators

You are discussing a workaround. It would be much better to  change the admin settings for the user profile fields that they can define visibility for each field, adding additional fields and ordering all types of fields.

The icq and aim fields are historical fields that most users are not using today. Adding fields for linkedin, facebook or other platforms would make more sense. But even this platforms will be outdated and replaced by other services like slack or whatever.

I think there is tracker issue to change this page features. Did not search for this now.

 
Average of ratings: -