1

I am having a hard time finding out why non admins (and anonymous users) are having "access denied" errors when looking at Drupal-7 profiles of other users.

The "View user profiles" permission is checked.

My user's profile page is a panel, but the 'access denied' errors even if the profile is not a panel.

Any idea? Please help.

Additional Information:

Using a code inspired by Yuriy Babenko's answer, and filterning for uniqueness, I see the following pemissions are denied when user 163 views the profile of user 174 (goes to /user/174) :

access administration menu
access administration pages
access all views
administer block classes
administer blocks
administer contexts
administer less
administer media
administer menu
administer user relationship
administer users
administer views
bypass node access
execute php code
view any private_notification content
view own unpublished content
view the administration theme

I don't see anything related to user access...

The nice Access Denied Backtrace module gives the following backtrace, but how to interpret it?

Array
(
    [ 2: drupal_deliver_page()] => Array
        (
            [file] => includes/common.inc:2564
            [args] => Array
                (
                    [0] => 3
                    [1] => 
                )

        )

    [ 1: menu_execute_active_handler()] => Array
        (
            [file] => includes/menu.inc:532
            [args] => Array
                (
                )

        )

    [ 0: main()] => Array
        (
            [file] => index.php:21
            [args] => Array
                (
                    [q] => user/174
                )

        )

)

HOTFIX: Adding the following code before line 820 of user.module temporarily solved the issue:

if (arg(0) == 'user' && is_numeric(arg(1)) && is_null(arg(2)) && 
    $string == 'administer users' ) {
  return TRUE;
}

But how do I find why the 'administer users' permission to view other user profiles?

1

Impossible to say exactly without having access to your site, but something ON the profile page is causing this.

Do this (assuming you're on Drupal 7):

  • Open /modules/user/user.module
  • Scroll down to line 820 (which should be: return isset($perm[$account->uid][$string]);)
  • Immediately above that line, add this code:

.

if (!isset($perm[$account->uid][$string])) {
  echo 'denied permission: ' . $string . '<br/>';
}
  • Reload the page as a user that's getting Access Denied, and you'll get a printout of all permissions the current user got denied - one (or more) of them will be the culprit.

Don't forget to remove the code changes once you've found the issue.

  • Thanks Yoriy, I tried it and added the answers I got to the question. Yet I see no permission related to users ... – Druvision Jan 29 '14 at 6:56
  • I've also added the output of the 'Access Denied Backtrace' module. – Druvision Jan 29 '14 at 7:33
0

This was a menu permission issue.

On my module's hook_menu_alter(), I printed the menu into the site's watchdog:

watchdog( 'fb_menu_alter', '<pre>'.print_r($items, true).'</pre>');

Looking at the results for the 'user' path, it was immediately clear that the access callback was old:

 [user/%user] => Array
    (
        [title] => My account
        [title callback] => user_page_title
        [title arguments] => Array
            (
                [0] => 1
            )

        [page callback] => user_view_page
        [page arguments] => Array
            (
                [0] => 1
            )

        [access callback] => privacypu_check_access
        [access arguments] => Array
            (
                [0] => 1
                [1] => profile
                [2] => access user profiles
            )

        [menu_name] => navigation
        [module] => user
    )

Disabling the privacypu_profile module resolved the issue.

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.