How to display a different theme based on the user programatically?

How to display a different theme based on the user programatically?

john felix - මගින්
Number of replies: 10

Hi,

  I was just wondering whether it is possible to change the theme programatically depending on who the current logged in user is? Can someone tell me how to do this.

 

Thanks

ශ්‍රේණිගත කිරීම්වල සාමාන්යය: -
In reply to john felix

Re: How to display a different theme based on the user programatically?

Richard Oelmann - මගින්
Core developers ගේ පින්තුරය Plugin developers ගේ පින්තුරය Testers ගේ පින්තුරය

Hi John,

I'm not sure about 'programmatically' but if you enable user themes in Site Admin > Appearance > Themes > Theme Settings, each user can then set a theme on their profile page. You can limit the choice of themes by creating a list on the theme settings page as well.

Richard

ශ්‍රේණිගත කිරීම්වල සාමාන්යය: Useful (1)
In reply to john felix

Re: How to display a different theme based on the user programatically?

Frederic Nevers - මගින්

Hi,

I've never tried it but there is a 'theme' field in the 'mdl-user' table. You could probably try and set a theme there (with PHPmyAdmin) to see if it works. Just a thought.

Cheers, 

Fred

ශ්‍රේණිගත කිරීම්වල සාමාන්යය: -
In reply to Frederic Nevers

Re: How to display a different theme based on the user programatically?

Mary Evans - මගින්
Core developers ගේ පින්තුරය Documentation writers ගේ පින්තුරය Peer reviewers ගේ පින්තුරය Plugin developers ගේ පින්තුරය Testers ගේ පින්තුරය

Hi,

This can be set in the students profile by the administrator, if this option is enabled in Theme settings, so no need to manually change the Database.

Cheers

Mary

ශ්‍රේණිගත කිරීම්වල සාමාන්යය: -
In reply to Mary Evans

Re: How to display a different theme based on the user programatically?

Arjun Baliga - මගින්

Dear All,

i have a similar question .I have set force theme  courses ,as we  have multiple courses running on same instanse.

and  i have set user theme in their profile for admin and teachers.is there any way i can stop overwriding user theme by course theme.

Hope i am making sense සිනහව thanks in advance 

Arjun 

ශ්‍රේණිගත කිරීම්වල සාමාන්යය: -
In reply to Arjun Baliga

Re: How to display a different theme based on the user programatically?

Tim Hunt - මගින්
Core developers ගේ පින්තුරය Documentation writers ගේ පින්තුරය Particularly helpful Moodlers ගේ පින්තුරය Peer reviewers ගේ පින්තුරය Plugin developers ගේ පින්තුරය

I don't think you can control this in the Moodle UI, but you can control it in your config.php file. If you look in config-dist.php, which lists all the things you can set in config.php, it is documented there. (Search for $CFG->themeorder).

ශ්‍රේණිගත කිරීම්වල සාමාන්යය: Useful (2)
In reply to Tim Hunt

Re: How to display a different theme based on the user programatically?

Arjun Baliga - මගින්

thanks much Tim ,what exactly i wanted 

ශ්‍රේණිගත කිරීම්වල සාමාන්යය: -
In reply to Arjun Baliga

Re: How to display a different theme based on the user programatically?

Phillip McAbee - මගින්

Hey Arjun,

Where able to display a different theme based on the user programmatically?

I have the same challenge? If you have anything to share on how to implement this it be great - I'm working with Moodle 2.7.

Phil

ශ්‍රේණිගත කිරීම්වල සාමාන්යය: -
In reply to Phillip McAbee

Re: How to display a different theme based on the user programatically?

Nick Garrod - මගින්

Did a solution get found for this.

I too want a theme automatically selected based on the user that has logged into the system.

ශ්‍රේණිගත කිරීම්වල සාමාන්යය: -
In reply to Nick Garrod

Re: How to display a different theme based on the user programatically?

Mary Evans - මගින්
Core developers ගේ පින්තුරය Documentation writers ගේ පින්තුරය Peer reviewers ගේ පින්තුරය Plugin developers ගේ පින්තුරය Testers ගේ පින්තුරය

Read the whole of this discussion. Admins can set a theme for a Student in the student's profile. However these themes can be overridden if course themes have been set too. To make the User theme dominate this action you would also need to add some php markup into your Moodle site's config.php.

Read Tim's comment above.

Cheers

Mary

ශ්‍රේණිගත කිරීම්වල සාමාන්යය: Useful (1)
In reply to Mary Evans

Re: How to display a different theme based on the user programatically?

Rodrigo Ribeiro de Abreu - මගින්

Thanks a lot. This thread helped me a lot.

I'm facing a challenge: I need that every new user starts using moodle with an especific theme.

In other words:

1 - a theme for Admin and non logged users

2 - 1 theme for every looged users (except for admin)



ශ්‍රේණිගත කිරීම්වල සාමාන්යය: -