• Resolved Tanveer

    (@tanver)


    Hi friends,
    I am working on a project where I need to restrict the contents [columns and no. of words to be displayed] based upon the role of the user, who is currently trying to access the contents.
    I am thinking of using User Based Page Templates like we do for page-catid.php etc but don’t know whether it is possible or not? I would appreciate any help/support from this wonderful community.
    TIA

Viewing 2 replies - 1 through 2 (of 2 total)
  • I believe that you could have a ‘parent’ template include the proper ‘child’ template based on the current user’s capability. Something like this (UNTESTED):

    if (current_user_can('administrator')) {
       include TEMPLATEPATH . '/admin-template.php';
    } elseif (current_user_can('editor')) {
       include TEMPLATEPATH . '/editor-template.php';
    } else {
       include TEMPLATEPATH . '/norole-template.php';
    }
    Thread Starter Tanveer

    (@tanver)

    Thanks for your support. 🙂
    It did the job, have to replace TEMPLATEPATH with STYLESHEETPATH for the templates to be based in the child theme folder.

Viewing 2 replies - 1 through 2 (of 2 total)
  • The topic ‘Using role based page templates?’ is closed to new replies.