コード例 #1
0
 function pwa_admin_url_redirect_conditions()
 {
     $getPwaOptions = get_pwa_setting_options();
     $pwaActualURLAry = array(home_url('/wp-login.php'), home_url('/wp-login.php/'), home_url('/wp-login'), home_url('/wp-login/'), home_url('/wp-admin'), home_url('/wp-admin/'));
     $request_url = pwa_get_current_page_url($_SERVER);
     $newUrl = explode('?', $request_url);
     //print_r($pwaActualURLAry); echo $newUrl[0];exit;
     if (!is_user_logged_in() && in_array($newUrl[0], $pwaActualURLAry)) {
         /** is forgot password link */
         if (isset($_GET['login']) && isset($_GET['action']) && $_GET['action'] == 'rp' && $_GET['login'] != '') {
             $username = $_GET['login'];
             if (username_exists($username)) {
                 //silent
             } else {
                 wp_redirect(home_url('/'), 301);
                 //exit;
             }
         } elseif (isset($_GET['action']) && $_GET['action'] == 'rp') {
             //silent
         } elseif (isset($_GET['action']) && isset($_GET['error']) && $_GET['action'] == 'lostpassword' && $_GET['error'] == 'invalidkey') {
             $redirectUrl = home_url($getPwaOptions["pwa_rewrite_text"] . '/?action=lostpassword&error=invalidkey');
             wp_redirect($redirectUrl, 301);
             //exit;
         } elseif (isset($_GET['action']) && $_GET['action'] == 'resetpass') {
             // silent
         } else {
             wp_redirect(home_url('/'), 301);
             //exit;
         }
         //exit;
     } else {
         if (isset($getPwaOptions['pwa_restrict']) && $getPwaOptions['pwa_restrict'] == 1 && is_user_logged_in()) {
             global $current_user;
             $user_roles = $current_user->roles;
             $user_ID = $current_user->ID;
             $user_role = array_shift($user_roles);
             if (isset($getPwaOptions['pwa_allow_custom_users']) && $getPwaOptions['pwa_allow_custom_users'] != '') {
                 $userids = explode(',', $getPwaOptions['pwa_allow_custom_users']);
                 if (is_array($userids)) {
                     $userids = explode(',', $getPwaOptions['pwa_allow_custom_users']);
                 } else {
                     $userids[] = $getPwaOptions['pwa_allow_custom_users'];
                 }
             } else {
                 $userids = array();
             }
             if ($user_role == 'administrator' || in_array($user_ID, $userids)) {
                 //silent is gold
             } else {
                 wp_redirect(home_url('/'));
                 //exit;
             }
         } else {
             //silent is gold
         }
     }
 }
コード例 #2
0
function pwa_admin_url_redirect_conditions()
{
    $getPwaOptions = get_pwa_setting_options();
    $pwaActualURLAry = array(str_replace('www.', '', home_url('/wp-login.php')), str_replace('www.', '', home_url('/wp-login.php/')), str_replace('www.', '', home_url('/wp-login')), str_replace('www.', '', home_url('/wp-login/')), str_replace('www.', '', home_url('/wp-admin')), str_replace('www.', '', home_url('/wp-admin/')));
    $request_url = pwa_get_current_page_url($_SERVER);
    $newUrl = explode('?', $request_url);
    // print_r($pwaActualURLAry); echo str_replace('www.','',$newUrl[0]);exit;
    $pwa_requestUrl = str_replace('www.', '', $newUrl[0]);
    if (!is_user_logged_in() && in_array($pwa_requestUrl, $pwaActualURLAry)) {
        wp_redirect(home_url('/'), 301);
        //exit;
    } else {
        if (isset($getPwaOptions['pwa_restrict']) && $getPwaOptions['pwa_restrict'] == 1 && is_user_logged_in()) {
            global $current_user;
            $user_roles = $current_user->roles;
            $user_ID = $current_user->ID;
            $user_role = array_shift($user_roles);
            if (isset($getPwaOptions['pwa_allow_custom_users']) && $getPwaOptions['pwa_allow_custom_users'] != '') {
                $userids = explode(',', $getPwaOptions['pwa_allow_custom_users']);
                if (is_array($userids)) {
                    $userids = explode(',', $getPwaOptions['pwa_allow_custom_users']);
                } else {
                    $userids[] = $getPwaOptions['pwa_allow_custom_users'];
                }
            } else {
                $userids = array();
            }
            if ($user_role == 'administrator' || in_array($user_ID, $userids)) {
                //silent is gold
            } else {
                wp_redirect(home_url('/'));
            }
        } else {
            //silent is gold
        }
    }
}