0

I'm customizing user profile page in my Drupal 7 site. I decided to remove menu tabs on the page by modifing template.php file with following code function my_theme_preprocess_page(&$variables){ unset($variables['tabs']); }
Insted of tabs I created block in user-profile.tpl.php and moved links from tabs there `

        <?php print l(t('Edit profile'), "user/{$GLOBALS['user']->uid}/edit"); ?>
    </div>
    <div class="user-profile-subscriptions">
        <?php print l(t('Subscriptions'), "user/{$GLOBALS['user']->uid}/subscriptions");?>
    </div>
</div>`

How can I configure permissions to display this block only whe user is viewing own profile and hide whe viewing profile of other user?

UPD: I assume this may be possible through comparing current user name user->name and user name from URL but I do not know how to extract user name from URL.

4
  • You can use user_access('administer users'). It returns TRUE if user have permission to edit profiles and FALSE otherwise.
    – Eugene
    Commented May 21, 2015 at 8:42
  • In my case only administrator has Administer users permission. So it does not work for users with different roles Commented May 21, 2015 at 8:52
  • Then you can define your own permission and alter the menu callback
    – Eugene
    Commented May 21, 2015 at 8:53
  • 1
    Get the user id using arg(1) (for any path in the form user/%).
    – Ben
    Commented May 21, 2015 at 14:16

0

Your Answer

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

Browse other questions tagged or ask your own question.