function filter_AdminUrl($url, $path) { if (strpos($path, 'profile.php') !== false && !am4PluginsManager::skipProtection() && am4PluginsManager::getOption('profile_redirect')) { return am4PluginsManager::getAPI()->getProfileURL(); } return $url; }
function run($atts = array(), $content = '') { $errors = am4Errors::getInstance(); if (!am4PluginsManager::getAPI()->isLoggedIn()) { return do_shortcode($errors->get($atts['guest_error'])); } if (!am4PluginsManager::getAPI()->isUserActive()) { return do_shortcode($errors->get($atts['user_error'])); } $access = new am4UserAccess(); //User is logged in let's check his access level; if ($atts['have']) { $records = $this->convertToAccessRequirement($atts['have']); if (!$access->anyTrue($records)) { return do_shortcode($errors->get($atts['user_error'])); } } if ($atts['not_have']) { $records = $this->convertToAccessRequirement($atts['not_have']); if (!$access->allFalse($records)) { return do_shortcode($errors->get($atts['user_error'])); } } return do_shortcode($content); }
function filter_TheContent($content) { $api = am4PluginsManager::getAPI(); if (am4PluginsManager::skipProtection()) { return $content; } $access = new am4UserAccess(); $type = $api->isLoggedIn() ? "user" : "guest"; if (is_single()) { $post = @$GLOBALS['post']; if (!$post) { return $content; } $settings = $this->getPostAccess($post); if ($settings->{'protected'} && (!$access->isLoggedIn() || !$this->haveAccess($this->getPostRequirements($post), $settings))) { switch ($settings->{$type . '_action'}) { case 'text': $content = $this->getErrorText($settings->{$type . '_action_text'}); break; } } } return $content; }
function after_login_widget($instance) { global $current_user; // Get current user's subscription and show usefull links; $amember_api = am4PluginsManager::getAPI(); $view = new am4View("widget_after_login"); $view->assign("instance", $instance); if ($amember_api->isLoggedIn()) { $view->assign("user", $amember_api->getUser()); $view->assign("links", $amember_api->getUserLinks()); } $view->assign('isLoggedIn', $amember_api->isLoggedIn()); $view->render(); }
function getAccessCache() { return am4PluginsManager::getAPI()->getAccessCache(); }
function run($atts = array(), $content = '') { $ret = ''; if (($api = am4PluginsManager::getAPI()) && $api->isLoggedIn()) { $user = $api->getUser(); $url = am4PluginsManager::getAmemberURL(); $vars = array('r' => $user['user_id']); if (array_key_exists('id', $atts) && $atts['id']) { $vars['i'] = $atts['id']; } if (array_key_exists('title', $atts) && $atts['title']) { $ret = sprintf("<a href='%s/aff/go?%s'>%s</a>", $url, http_build_query($vars, '', '&'), $title); } else { $ret = sprintf("%s/aff/go?%s", $url, http_build_query($vars, '', '&')); } } return $ret; }
function filter_TheContent($content) { $api = am4PluginsManager::getAPI(); if (current_user_can("manage_options")) { return $content; } $access = new am4UserAccess(); $type = $api->isLoggedIn() ? "user" : "guest"; if (is_single()) { $post = $GLOBALS['post']; if (!$post) { return $content; } $settings = $this->getPostAccess($post); if ($settings['protected'] && (!$access->isLoggedIn() || !$access->anyTrue($this->getPostRequirements($post)))) { switch ($settings[$type . '_action']) { case 'text': $content = $this->getErrorText($settings[$type . '_action_text']); break; } } } return $content; }