template.php check user and profile
This is not something that should be done in the theme layer. I would look at solutions like ACL or Content Access.

If you really need to code your own solution for some reason, create a custom module and use the necessary hooks, such as hook_permission.