Support for Drupal 7 is ending on 5 January 2025—it’s time to migrate to Drupal 10! Learn about the many benefits of Drupal 10 and find migration tools in our resource center.
By Hubert_r on
Hi there,
Does anyone know how to tell Drupal 7 *not* to use the admin theme for the user edit page?
Specifically, what I m trying to do is to have the default theme when a user edits his own profile, and the admin theme when editing someone else's profile (which typically would be done by an administrator from the admin/people section).
I've tried using hook_custom_theme, which works fine when I tested it for regular pages, but for some reason is ignored when I'm on the user edit page.
function mymodule_custom_theme() {
global $user;
// if we're on the user edit page
if (arg(0) == 'user' && is_numeric(arg(1)) && arg(2) == 'edit') {
// if the user is editing his own profile
if (arg(1) == $user->uid) {
return 'my-default-theme';
}
// if editing someone else's profile
else {
return variable_get('admin_theme');
}
}
return;
}
Thanks a lot for any suggestions!
Comments
Did you ever get a solution
Did you ever get a solution to this? I've just run into it also.
You may implement the
You may implement the hook_admin_paths_alter hook
Hope this helps.
Thanks, @lucor - very
Thanks, @lucor - very helpful.
thx for your sollution!
thx for your sollution!
http://www.wbase.be twitter: @wbase_be
Thanks for sharing, lucor
Thanks for sharing, lucor
Works great!
Thanks!
Thanks!
Did this work on Drupal 8.x?
Hi Webteam.su,
Going by the time of your comment, I am guessing you have tried Lucor's solution on Drupal 8. I am trying to do the same with Drupal 8.4.4 but it does not seem to work. The API reference pages also don't seem to list hook_admin_paths_alter as a valid hook.
Is there a different way to achieve this in Drupal 8?
I'm also interested on a
I'm also interested on a official solution in Drupal 8 for both edit and view page, even when logged with administrator.
--
by FiNeX
FiNeX.org
Siti Web Vicenza
Works like a charm...
...6 years later @ lucor. Thanks a bunch!
Have you disabled the theme
Subscribed.