/** * Get conditional restrictions * and authorize access for user * * @since 0.1 * @return void */ public function authorize_access() { if ($this->_has_global_access()) { return; } $posts = WPCACore::get_posts(RUA_App::TYPE_RESTRICT); if ($posts) { $kick = 0; $levels = array_flip($this->_get_user_levels()); foreach ($posts as $post) { if (!isset($levels[$post->ID])) { $kick = $post->ID; } else { $kick = 0; break; } } if ($kick) { $action = $this->metadata()->get('handle')->get_data($kick); self::$page = $this->metadata()->get('page')->get_data($kick); switch ($action) { case 0: if (self::$page != get_the_ID()) { wp_safe_redirect(get_permalink(self::$page)); exit; } break; case 1: add_filter('the_content', array($this, 'content_tease'), 8); break; default: break; } return; } } }