How to hide elements on User Profile page?

How to hide elements on User Profile page?

by Arturs Polis -
Number of replies: 2

Hi!

I want to clean up the User Profile page by hiding everything except the User details. I have played around the User roles and Permissions for a while, permitting block viewing etc. However, the following fields are still there:

  • Course details
  • Miscellaneous
  • Reports
  • Login activity

Then I applied the CSS, which did not work either:

  • .node_category:nth-child(2) { display: none; }
  • .node_category:nth-child(3) { display: none; }
  • .node_category:nth-child(4) { display: none; }
  • .node_category:nth-child(5) { display: none; }

The only thing that worked was coloring these elements transparent. But this is a bad solution, of course. 

  • .node_category:nth-child(2) { color: transparent; }
  • .node_category:nth-child(3) { color: transparent; }
  • .node_category:nth-child(4) { color: transparent; }
  • .node_category:nth-child(5) { color: transparent; }

What else could I try out? 
Please, help. 

Average of ratings: Useful (1)
In reply to Arturs Polis

Re: How to hide elements on User Profile page?

by Jérôme Mouneyrac -

Hi Arturs,

many things can be hidden from Moodle administration. Search in the admin for hiddenuserfields, you should be able to disable most things.

For this same reason I advice to not hide things with CSS as you can not trigger the exact element with a class or id. To hide it by CSS you would need to do like you suggest some hierarchy selection which would be obviously failing to select the right things if someone else would come later to change the hiddenuserfields settings.

At the moment, the most efficient/maintainable imo (and known as ugly as it is a core hack) is to change the output renderer. For example to hide miscellaneous in user/classes/output/myprofile/renderer.php

foreach ($categories as $category) {
            if ($category->name !== 'miscellaneous') {
                $return .= $this->render($category);
            }
        }
Also what would be good is to create an issue in the tracker to support missing section like miscellaneous.


Cheers,
Jerome

Average of ratings: Useful (1)
In reply to Jérôme Mouneyrac

Re: How to hide elements on User Profile page?

by Miguel Penilla -

Hi, I have been trying to hide the MISCELLANEOUS element on the User Profile page, I found this thread and when i tried to follow the steps you have mentioned i could´t  find those lines in user/classes/output/myprofile/renderer.php

all i find is

  public function render_tree(tree $tree) {
        $return = \html_writer::start_tag('div', array('class' => 'profile_tree'));
        $categories = $tree->categories;
       
        foreach ($categories as $category) {
            $return .= $this->render($category);
        }
        $return .= \html_writer::end_tag('div');
        return $return;
    }

I use Moodle 3.0.3+ (Build: 20160407)


Thanks for your advice on this issue


Sincerely


Miguel