/**
  * getUserAccess function.
  * 
  * @access public
  * @param WP_User $user
  * @return boolean
  */
 function getUserAccess($user)
 {
     $role_access = false;
     $form = new WPSDAdminConfigForm();
     $role_author = $form->getWpsdRoleAuthor();
     $role_editor = $form->getWpsdRoleEditor();
     $role_subscriber = $form->getWpsdRoleSubscriber();
     $role_contributor = $form->getWpsdRoleContributor();
     if (null != $user) {
         if ($user->caps['editor'] && $role_editor) {
             $role_access = true;
         } else {
             if ($user->caps['author'] && $role_author) {
                 $role_access = true;
             } else {
                 if ($user->caps['contributor'] && $role_contributor) {
                     $role_access = true;
                 } else {
                     if ($user->caps['subscriber'] && $role_subscriber) {
                         $role_access = true;
                     } else {
                         if ($user->caps['administrator']) {
                             $role_access = true;
                         }
                     }
                 }
             }
         }
     }
     return $role_access;
 }
示例#2
0
/**
 * wpsd_has_access function.
 * 
 * @access public
 * @return void
 */
function wpsd_has_access()
{
    $role_access = false;
    $form = new WPSDAdminConfigForm();
    $role_author = $form->getWpsdRoleAuthor();
    $role_editor = $form->getWpsdRoleEditor();
    $role_subscriber = $form->getWpsdRoleSubscriber();
    $role_contributor = $form->getWpsdRoleContributor();
    $user = wp_get_current_user();
    if (null != $user) {
        if ($user->caps['editor'] && $role_editor) {
            $role_access = true;
        } else {
            if ($user->caps['author'] && $role_author) {
                $role_access = true;
            } else {
                if ($user->caps['contributor'] && $role_contributor) {
                    $role_access = true;
                } else {
                    if ($user->caps['subscriber'] && $role_subscriber) {
                        $role_access = true;
                    }
                }
            }
        }
    }
    return $role_access;
}