I'm using breadcrumbs in my drupal 7 website.

How and where do I change the URL for the [home] breadcrumb, based on role/authentication of the user - when the authenticated user signs in, they are taken to role based page, when they hit the home breadcrumb, I want them taken back to their role-based home page/url, not the main/anonymous user home page.

I think I want to add a preprocessor function to the template.php that will say--> function themename_breadcrumb() {if auth_user home url is $this else $homeURL is $this}. How would I write this?

  • Interesting. What about you make the "role-based homepage" available under the root url when logged in? This way the breadcrumb can stay the same, only the page contents change. You could still make the original public homepage available somewhere else then..
    – donquixote
    Commented Sep 18, 2014 at 4:15
  • Also, is this really the purpose of a breadcrumb? Or should the breadcrumb not rather link to the "real" homepage, and then another link somewhere to link to the role-based page? A breadcrumb should present the site hierarchy, but it does not seem that a role-based page is an "ancestor" of other pages.
    – donquixote
    Commented Sep 18, 2014 at 4:17

2 Answers 2


You could use the theme_breadcrumb hook and change the link for the home breadcrumb by checking the role of the currently logged in user.

I've put some sample code in below, but I am assuming that your breadcrumbs array will always have the 'Home' breadcrumb as the first element.

This code should go in template.php

function yourtheme_breadcrumb($variables) {
  global $user;
  $breadcrumb = $variables['breadcrumb'];

  if (!empty($breadcrumb)) {  

    // Check if the user has the right role.
    if(in_array('your_role', $user->roles)) {
      $breadcrumb[0] = l('Home', 'path-to-role-homepage');

    $output = '<h2 class="element-invisible">' . t('You are here') . '</h2>';
    $output .= '<div class="breadcrumb">' . implode(' » ', $breadcrumb) .'</div>';
    return $output;

Hope that helps out.

  • I will find out today Kunoichi - Yes, you are correct, my bc array will always have the home bc. I will let you know how it works. Thank your for the suggestion. Commented Sep 18, 2014 at 12:32
  • Sorry Kunoichi, it's been crazy around, forgot to come back and tell THANK YOU! - this worked perfectly. Commented Oct 6, 2014 at 17:56

I think you could use the Rules module to redirect from the root page to the desired page if the user has the selected role.

  • This is an interesting idea betherwisser. Don't think I will use it in this instance, but will tuck away in my back-pocket for future projects as I have not used Rules very often in the past. Commented Sep 18, 2014 at 12:34

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.