Want to make my own sidebar but how do I get what should appear?

ultimante - February 4, 2006 - 23:02

I want to make my own custom user menu and do away with the sidebar, only keeping it for admins. Things like, instead of a create content button that expands, I'll just have a couple buttons for things I want users to be able to do in my own div tag.

For example, how do I determine if a user has/can create a blog based on their permissions. The sidebar knows and if they can, has a My Blog link. I want to be able to do that, as well, for many of the items.

Some users will be able to post certain types of content, and I just want to make everything custom to look exactly how I want it to. I've been trying to find where these permissions come from in the php with no luck so I thought I'd ask here while I continue to search the includes.

user_access

DriesK - February 5, 2006 - 02:29

You can check permissions for the current user with user_access(). For example:

<?php
if (user_access('create pages')) {
  print
l('Create a new page', 'node/add/page');
}
?>

(this example also uses the l()-function, which is better than hardcoding the a-tag)

So any permission that is available in 'administer'->'access control' can be given as an argument to user_access(). For further information on this function, see drupaldocs.

 
 

Drupal is a registered trademark of Dries Buytaert.