本文整理汇总了PHP中auth_redirect函数的典型用法代码示例。如果您正苦于以下问题:PHP auth_redirect函数的具体用法?PHP auth_redirect怎么用?PHP auth_redirect使用的例子?那么, 这里精选的函数代码示例或许可以为您提供帮助。
在下文中一共展示了auth_redirect函数的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: template_redirect
/**
* Output the POS template
*/
public function template_redirect()
{
// check is pos
if (!is_pos('template')) {
return;
}
// check auth
if (!is_user_logged_in()) {
add_filter('login_url', array($this, 'login_url'));
auth_redirect();
}
// check privileges
if (!current_user_can('access_woocommerce_pos')) {
/* translators: wordpress */
wp_die(__('You do not have sufficient permissions to access this page.'));
}
// disable cache plugins
$this->no_cache();
// last chance before template is rendered
do_action('woocommerce_pos_template_redirect');
// add head & footer actions
add_action('woocommerce_pos_head', array($this, 'head'));
add_action('woocommerce_pos_footer', array($this, 'footer'));
// now show the page
include 'views/template.php';
exit;
}
示例2: login_redirect
/**
* Redirected den Besucher zur Login page, aber nur, wenn dieser nicht eingelogged ist.
*/
function login_redirect()
{
if (!is_user_logged_in()) {
auth_redirect();
//https://codex.wordpress.org/Function_Reference/auth_redirect
}
}
示例3: fx_private_site_please_log_in
/**
* Redirects users that are not logged in to the 'wp-login.php' page.
* This function is taken from Private Site Feature in "Members" Plugin.
*
* @since 0.1.0
* @author Justin Tadlock <justin@justintadlock.com>
* @copyright Copyright (c) 2009 - 2016, Justin Tadlock
*/
function fx_private_site_please_log_in()
{
/* Check if the private site feature is active and if the user is not logged in. */
if (true === fx_private_site_get_option('enable', false) && !is_user_logged_in()) {
/* Hook */
do_action('fx_private_site_before_auth_redirect');
/* If using BuddyPress and on the register page, don't do anything. */
if (function_exists('bp_is_activation_page') && bp_is_activation_page()) {
return;
}
if (function_exists('bp_is_register_page') && bp_is_register_page()) {
return;
}
/* WooCommerce: Whitelist My Account Page */
if (class_exists('WooCommerce')) {
$myaccount_page_id = get_option('woocommerce_myaccount_page_id');
if ($myaccount_page_id && is_page($myaccount_page_id)) {
return;
}
}
/* Redirect to the login page. */
auth_redirect();
exit;
}
}
示例4: template_files
public function template_files($template_path)
{
global $post;
if ($post) {
if ('question' == get_post_type() || is_tax('question_category') || ap_opt('base_page') == $post->ID || ap_opt('ask_page') == $post->ID || ap_opt('edit_page') == $post->ID || ap_opt('a_edit_page') == $post->ID || ap_opt('categories_page') == $post->ID || ap_opt('tags_page') == $post->ID || ap_opt('users_page') == $post->ID) {
$template_path = ap_get_theme_location('index.php');
}
}
if (is_tax('question_category') || is_tax('question_tags')) {
$template_path = ap_get_theme_location('index.php');
}
if ('answer' == get_post_type()) {
if (is_single()) {
global $post;
wp_redirect(get_permalink($post->post_parent));
exit;
}
}
if ($post && ap_opt('ask_page') == $post->ID) {
if (!is_user_logged_in()) {
auth_redirect();
}
}
return $template_path;
}
示例5: i4_force_login
/**
* Forces Login by redirecting to the login page by using the pluggable core function that redirects to
* the page trying to be accessed after the user has logged in
*
*/
public function i4_force_login()
{
if (!is_user_logged_in()) {
//Redirect the user if they are not authenticated
auth_redirect();
}
}
示例6: aioi_template_redirect
public function aioi_template_redirect()
{
if (substr($_SERVER['REQUEST_URI'], 0, 16) == '/wp-activate.php') {
return;
}
if (substr($_SERVER['REQUEST_URI'], 0, 11) == '/robots.txt') {
return;
}
$options = $this->get_option_aioi();
if (!$options['aioi_privatesite']) {
return;
}
// We do want a private site
if (!is_user_logged_in()) {
auth_redirect();
} else {
if (is_multisite()) {
$this->handle_private_loggedin_multisite($options);
} else {
// Bar access to users with no role
$user = wp_get_current_user();
if (!$user || !is_array($user->roles) || count($user->roles) == 0) {
wp_logout();
$output = '<p>' . esc_html('You attempted to login to the site, but you do not have any permissions. If you believe you should have access, please contact your administrator.') . '</p>';
wp_die($output);
}
}
}
}
示例7: aceify_force_login
function aceify_force_login()
{
global $post;
if ((is_single() || is_front_page() || is_page()) && !is_page('login') && !is_user_logged_in()) {
auth_redirect();
}
}
示例8: enforce_privacy_redirect
/**
* Check if privacy enforcement is enabled, and redirect users that aren't
* logged in.
*/
function enforce_privacy_redirect()
{
if ($this->settings->enforce_privacy && !is_user_logged_in()) {
// our client endpoint relies on the wp admind ajax endpoint
if (!defined('DOING_AJAX') || !DOING_AJAX || !isset($_GET['action']) || $_GET['action'] != 'openid-connect-authorize') {
auth_redirect();
}
}
}
示例9: fl_check_user
/**
* force_login() - checks if a wp_user is logged in. If not, it redirects them to the login page
*
* will redirect to the login page if not
**/
function fl_check_user()
{
$current_file_name = basename($_SERVER['REQUEST_URI'], ".php");
/* supposing filetype .php*/
$fname = substr($current_file_name, 0, 8);
if (!is_user_logged_in() && $fname != "wp-login") {
auth_redirect();
}
}
示例10: default_action
/**
* set default action
*/
public function default_action()
{
require_once ABSPATH . 'wp-admin/includes/admin.php';
auth_redirect();
if (!empty($_POST['task']) && $_POST['task'] == 'contactform.export' && !empty($_POST['form_id'])) {
self::task_export();
}
exit;
}
示例11: default_action
/**
* set default action
*/
public function default_action()
{
require_once ABSPATH . 'wp-admin/includes/admin.php';
auth_redirect();
header('Content-Type: application/javascript');
$jsHook = array();
$jsHook['button-addnew-action'] = '$("#wpbody-content .jsn-form-title-heading h2").after(
$("<div/>", {"class":"contactform-add-new"}).append(
$("<a/>", {"text":"Add New", "href":"javascript:void(0);"})
).append(
$("<ul/>", {"class":"contactform-sample-form"}).append(
$("<li/>").append(
$("<a/>", {"class":"", "href":"post-new.php?post_type=wr_cf_post_type", "text":"Blank Form"})
)
)
)
);';
$jsHook = apply_filters('wr_contactform_js_forms_hook', $jsHook);
$javascript = '(function ($) {
$(function () {
$(".jsn-modal-overlay,.jsn-modal-indicator").remove();
$("body").append($("<div/>", {
"class":"jsn-modal-overlay",
"style":"z-index: 1000; display: inline;"
})).append($("<div/>", {
"class":"jsn-modal-indicator",
"style":"display:block"
})).addClass("jsn-loading-page");
$("#wpbody-content h2 .add-new-h2").hide();
$("#search-submit").val(\'Search Forms\');
$("#wpbody-content h2 .add-new-h2").parent().after(
$("<div/>", {"class":"jsn-form-title-heading"})
);
$("#wpbody-content h2 .add-new-h2").parent().appendTo($("div.jsn-form-title-heading"));
' . implode('', $jsHook) . '
$("#wpbody-content .contactform-add-new > a").click(function () {
if ($(".contactform-add-new").hasClass("active")) {
$(".contactform-add-new").removeClass("active");
} else {
$(".contactform-add-new").addClass("active");
}
return false;
});
$(document).click(function () {
$(".contactform-add-new").removeClass("active");
});
setTimeout(function () {
$("#wpbody-content").show();
$(".jsn-modal-overlay,.jsn-modal-indicator").remove();
}, 500);
});
})(jQuery);';
echo '' . $javascript;
exit;
}
示例12: handle_request
/**
* Handle request to authorization page
*
* Handles response from {@see render_page}, then exits to avoid output from
* default wp-login handlers.
*/
public function handle_request()
{
// Ensure visitors are logged in before serving authorization page
auth_redirect();
$response = $this->render_page();
if (is_wp_error($response)) {
$this->display_error($response);
}
exit;
}
示例13: controller
/**
* load only on Gmedia admin pages
*/
public function controller()
{
$this->user_options = self::user_options();
$view = $this->gmediablank ? '_frame' : '';
$this->display_mode = $this->user_options["display_mode_gmedia{$view}"];
if (!$this->page || strpos($this->page, 'GrandMedia') === false) {
return;
}
auth_redirect();
$this->processor();
}
示例14: members_please_log_in
/**
* Redirects users that are not logged in to the 'wp-login.php' page.
*
* @since 0.1.0
* @uses is_user_logged_in() Checks if the current user is logged in.
* @uses auth_redirect() Redirects people that are not logged in to the login page.
*/
function members_please_log_in()
{
/* Check if the private blog feature is active. */
if (members_get_setting('private_blog')) {
/* If using BuddyPress and on the register page, don't do anything. */
if (function_exists('bp_is_current_component') && bp_is_current_component('register')) {
return;
} elseif (!is_user_logged_in()) {
auth_redirect();
}
}
}
示例15: __construct
/**
*
*/
public function __construct($i_action, array $i_params)
{
$this->parse_get();
$this->parse_post();
$this->id = $this->get_id();
$this->action = $i_action;
$this->params = $i_params;
$this->vars = (object) $this->vars;
if ($this->validate_user_access() === false) {
header('HTTP/1.1 403 Forbidden');
\auth_redirect();
}
}