I want to modify the primary and secondary links sections in Xtemplate so the 'edit primary links' and 'edit secondary links' do not show up unless the user is an administator.

I believe this requires PHP and a snippet of code to determine if the current user is an admin.

Does anyone have some code which can do that check?

I suppose I have to check first whether PHP code can be used in that section?

Comments

kadimi’s picture

function has_role($role = 'administrator'){
  global $user ;

  if(!is_string($role))
    return FALSE;
  if(in_array($role, array_values($user->roles)))
    return TRUE;
}

if (has_role('administrator')){
  echo 'Welcome admin!';
}