General developer forum

Change moodle Theme as per user email address

 
Picture of Baiju Sharma
Change moodle Theme as per user email address
 

I would like to change Moodle theme as per user login.

Eg: If a student X login then moodle theme "magazine" should be shown to the user. If a student Y then moodle theme "aardvark" should be shown to the user.

I have installed both the theme in Moodle.

There is a column "theme" in a table called "mdl_user".

I have tried adding theme value into "mdl_user" table for a user, but no luck.

Thank you.

 
Average of ratings: -
Picture of Alexander Bias
Re: Change moodle Theme as per user email address
Core developersParticularly helpful MoodlersPlugin developers

Hi Baiju,

you don't exactly describe how you want to decide which theme to deliver. You say that you want to change the theme based on the email address, but what's the exact decision?

If you have any possibility to decide which theme to choose based on a user's custom profile field value, this plugin might be for you: https://github.com/moodleuulm/moodle-local_profiletheme

Thanks,
Alex

 
Average of ratings: -
Picture of Ken Task
Re: Change moodle Theme as per user email address
Particularly helpful Moodlers

Not sure you can do this prior to login ... once logged on, however, then the users preference for a theme IF allowed to change themes is set at the user level.

Search your admin menu for "theme" and you should find the options for themes.

Direct manipulation of DB is never considered a solution ... or so I've read.

I can think of a couple of potential issues ...

1. once one sets up accounts via editing DB to a theme, what prevents them from changing the theme?   It's a user preference.   Guess you could hack the dashboard or whatever screen a student would see via css and hide the field for theme preference.  Once one starts down that road (hacking code) it could make your next update/upgrade more 'complicated'.

2. certain themes have special process should an update be needed.   While you as the admin user can accomplish those students cannot.   This to say, if a students theme goes wonky it might make support more complicated for you.

Others might know a way that's flawless ...  otherwise, my 2 cent advice ... it's your Moodle! ;)

'spirit of sharing', Ken


 
Average of ratings: -
Picture of Richard Oelmann
Re: Change moodle Theme as per user email address
Core developersParticularly helpful MoodlersPlugin developersTesters

In Theme Settings, you will need to enable allowing user themes

 
Average of ratings: Useful (2)
Picture of Baiju Sharma
Re: Change moodle Theme as per user email address
 

From where I will get the value or name of the theme which I will be adding associative to the user in mdl_user table in theme column.

 
Average of ratings: -
Picture of Richard Oelmann
Re: Change moodle Theme as per user email address
Core developersParticularly helpful MoodlersPlugin developersTesters
You can find the correct name to use for each theme in its version.php file
 
Average of ratings: -