kundius

WP_check_user_access

Jun 19th, 2014
700
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
PHP 0.46 KB | None | 0 0
  1. function check_user_access( $p = null, $user_id = null ) {
  2.     if(empty($p))
  3.         $id = get_the_ID();
  4.     else
  5.         $id = is_string($p)?url_to_postid( $p ):$p;
  6.        
  7.     $access =  get_post_meta( $id, 'meta_restricting_access' );
  8.     if(is_array($access[0]) && !empty($access[0])) {
  9.         foreach($access[0] as $a) {
  10.             if(check_user_role($a, $user_id))
  11.                 return true;
  12.         }
  13.         return false;
  14.     }
  15.     return true;
  16. }
Advertisement
Add Comment
Please, Sign In to add comment