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

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

by Worawat Lawanont -
Number of replies: 39

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: -
In reply to Worawat Lawanont

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

by Shashikant Vaishnav -

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)
In reply to Shashikant Vaishnav

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

by Julio Fernández Avancini -

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.

In reply to Julio Fernández Avancini

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

by Jon Bolton -
Picture of Particularly helpful Moodlers Picture of Testers

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 (12)
In reply to Jon Bolton

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

by Debbie Kay -

Many thanks Jon!

In reply to Jon Bolton

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

by Sidd Lep -

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)
In reply to Sidd Lep

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

by Jon Bolton -
Picture of Particularly helpful Moodlers Picture of Testers

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 (7)
In reply to Jon Bolton

Odp: Re: Odgovor: Re: How to remove user's field when creating or editing users' profile

by Łukasz Sanokowski -

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?

In reply to Łukasz Sanokowski

Re: Odp: Re: Odgovor: Re: How to remove user's field when creating or editing users' profile

by Jon Bolton -
Picture of Particularly helpful Moodlers Picture of Testers
div#fitem_id_city {display: none;}
div#fitem_id_timezone  {display: none;}
Average of ratings: Useful (4)
In reply to Jon Bolton

回應: Re: Odp: Re: Odgovor: Re: How to remove user's field when creating or editing users' profile

by ray cheng -

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

In reply to ray cheng

Re: 回應: Re: Odp: Re: Odgovor: Re: How to remove user's field when creating or editing users' profile

by Phuong Hoang -

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


In reply to Jon Bolton

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

by Sam Suresh -
Picture of Plugin developers

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). 

In reply to Sam Suresh

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

by Michael Milette -
Picture of Core developers Picture of Documentation writers Picture of Particularly helpful Moodlers Picture of Plugin developers Picture of Testers Picture of Translators

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

In reply to Michael Milette

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

by Terry Aulenbach -

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.

In reply to Terry Aulenbach

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

by Michael Milette -
Picture of Core developers Picture of Documentation writers Picture of Particularly helpful Moodlers Picture of Plugin developers Picture of Testers Picture of Translators

Hi Terry,

If your theme does not include support for custom CSS, just go to Site Administration > Appearance > Additional HTML and add the following in the Within HEAD field:

<style>
    #fitem_id_url,
    #fitem_id_icq,
    #fitem_id_skype,
    #fitem_id_aim,
    #fitem_id_yahoo,
    #fitem_id_msn,
    #fitem_id_idnumber {
        display:none;
    }
</style>

Be sure to include the <style> and </style> tags. 

The Within HEAD section will insert whatever you enter in the <head> </head> section of your pages. If you are using multiple themes on your site, be aware that this setting applies across your whole site, not just to one theme.

You can actually use the fields listed on that page to add just about anything to your site such as addtitional meta tags, link in some fonts, CSS and JavaScript.

Hope this helps.

Best regards,

Michael Milette

In reply to Michael Milette

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

by Terry Aulenbach -

Sorry it took so long to get a chance to try this out. It kinda worked, but not exactly. However, Sean's entry below has worked for me.

In reply to Michael Milette

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

by Sam Mudle -
Confirmed working in Moodle 3.5.1
In reply to Sam Mudle

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

by Terry Aulenbach -

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

In reply to Michael Milette

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

by Aditya Saraiya -
What would be the statement for removing the field additional name in within head field ?
In reply to Aditya Saraiya

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

by Jon Bolton -
Picture of Particularly helpful Moodlers Picture of Testers

If your theme supports Custom CSS (and most do), it’s much better to use that instead.

fieldset#id_moodle_additional_names {display: none;}

If you HAVE to use the Additional HTML option, then use

fieldset#id_moodle_additional_names {display: none;}

In reply to Sam Suresh

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

by Michael Milette -
Picture of Core developers Picture of Documentation writers Picture of Particularly helpful Moodlers Picture of Plugin developers Picture of Testers Picture of Translators

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: Useful (1)
In reply to Michael Milette

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

by Chardelle Busch -
Picture of 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. 


In reply to Jon Bolton

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

by Ruchi Dixit -

Thanks

In reply to Jon Bolton

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

by John Graham -

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

In reply to John Graham

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

by Chardelle Busch -
Picture of 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)
In reply to Chardelle Busch

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

by John Graham -

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.

In reply to John Graham

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

by Chardelle Busch -
Picture of 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.

In reply to Chardelle Busch

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

by John Graham -

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.

In reply to John Graham

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

by Sean Marx -
Picture of Testers

Hi John

I know this is a late response, but it may help others coming to this page. I used the following css to hide both the label and the field. I got the suggestion from another post on this site, so hopefully it works for you {Moodle 3.5)


fieldset#id_moodle_optional .fcontainer .form-group:nth-child(1) {    display: none;}

fieldset#id_moodle_optional .fcontainer .form-group:nth-child(2) {    display: none;}

fieldset#id_moodle_optional .fcontainer .form-group:nth-child(3) {    display: none;}

fieldset#id_moodle_optional .fcontainer .form-group:nth-child(4) {    display: none;}

fieldset#id_moodle_optional .fcontainer .form-group:nth-child(5) {    display: none;}

fieldset#id_moodle_optional .fcontainer .form-group:nth-child(6) {    display: none;}

Average of ratings: Useful (2)
In reply to Sean Marx

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

by Terry Aulenbach -

Thank you, Sean! This is exactly what I needed. 

In reply to Jon Bolton

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

by Mohammad Nabil -
where can i put this code?
via cpanel file manger ? ot in moodle site adminstration
In reply to Julio Fernández Avancini

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

by William Bergman -

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.



In reply to William Bergman

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

by Michael Milette -
Picture of Core developers Picture of Documentation writers Picture of Particularly helpful Moodlers Picture of Plugin developers Picture of Testers Picture of Translators

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;
}

In reply to Michael Milette

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

by Yoel Gutierrez -

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

In reply to Yoel Gutierrez

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

by Chardelle Busch -
Picture of 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

In reply to Michael Milette

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

by Ralf Hilgenstock -
Picture of Core developers Picture of Particularly helpful Moodlers Picture of Translators

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.

In reply to Ralf Hilgenstock

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

by Luis de Vasconcelos -
Average of ratings: Useful (2)
In reply to Luis de Vasconcelos

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

by Michael Milette -
Picture of Core developers Picture of Documentation writers Picture of Particularly helpful Moodlers Picture of Plugin developers Picture of Testers Picture of Translators
Hi Luis, thanks for sharing the link. I just added my opinion to the ticket you referenced which, in my view, has not been addressed for far too long.