I am giving user the option of selecting the color(color scheme option like bartik) for the theme.For multiple users how do i save there color values for the theme and show their values alone depending on their login ? Colors for their header ,footer etc...

Help me provide with a solution.Thanks in advance


well, usually there are pre-defined color sets (like in batrik), so you save set name and then on hook_preprocess_page you chose which css to include. So either this or you can add inline css styling using the same function drupal_add_css.

As for how to save this for each user, you can add extra field to user profile at Home » Administration » Configuration » People » Account settings and then programmatically update it with needed value - example below, details here.

global $user;
$existing = user_load($uid);
$edit = (array) $existing;
$edit['field_somefield']['und'][0]['value'] = 'blah';
user_save($user, $edit);
  • In a single site i am trying to give each user there own option of changing colors(example: changing header color,footer color etc like bartik theme). For that to happen what i did is actually tried creating each user a their own css files in (sites/default/files/color/1-firehouse/colors.css) and generate it. Depending upon the user logged in i am including the generated css file alone. So it works properly. – Ram Aug 4 '13 at 13:06
  • But only issue over here is that, when i try once again to change the theme colors(header,footer etc) after logged in, if some other user has changed previously their colors, that is applied in view section alone(color scheme options) instead of current logged in user color scheme options. Just viewing of colors alone.Colors are applying properly.Only color scheme default value option is not user selected one. – Ram Aug 4 '13 at 13:08
  • I tried debugging it in color module. This is the function color_get_info i think which is responsible in rendering the color information for a particular theme, but i dont know how to make it load user selected css,but way too complex. I have digged much deeper into this, so i expect some results from this. Any help will be really appreciated :) – Ram Aug 4 '13 at 13:23
  • Hope you understood the way i am trying to do it? – Ram Aug 4 '13 at 15:13
  • How do you change colors for logged in users? – 32i Aug 6 '13 at 9:39

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.