Title basically. My hook_custom_theme() has been working for ages and I only just realised the admin theme is being served for an error when saving a user form ie. mismatched passwords.

A snippet from the top of my function:

function custom_theme_change_custom_theme() {
    global $top_bar_color;
    $top_bar_color = '#2b3643';
    if (strpos($_SERVER['HTTP_HOST'], 'example.com') !== false) {
        switch (returnRoleForTheme()) {
            case 'old': $th = 'theme_1'; $top_bar_color = '#2b3643'; break;
            case 'young': $th = 'theme_2'; $top_bar_color = '#6dad19'; break;
            case 'kid': $th = 'theme_3'; $top_bar_color = '#6dad19'; break;
    return $th;

Any ideas on how to force the theme like for every other part of the website? Why would this page in particular revert to Adminimal?

1 Answer 1


hook_custom_theme()'s documentation says :

The return value of this hook will be used on all pages except those which have a valid per-page or per-section theme set via a theme callback function in hook_menu(); the themes on those pages can only be overridden using hook_menu_alter().

so i guess that what you need here is having your custom rules ina helper function that you call both in hook_custom_theme() and the theme callback of the error page from hook_menu_alter()

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

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