Warning: file_get_contents(/data/phpspider/zhask/data//catemap/1/php/299.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Php 正在检查网站中的用户访问特定url_Php_Wordpress_Redirect_Woocommerce - Fatal编程技术网

Php 正在检查网站中的用户访问特定url

Php 正在检查网站中的用户访问特定url,php,wordpress,redirect,woocommerce,Php,Wordpress,Redirect,Woocommerce,我想在用户访问我网站中的特定URL时执行一些操作 add_action('template_redirect', 'woocommerce_custom_redirections'); function woocommerce_custom_redirections() { $MyLoginURL = "https://example.com/?login=true&page=4"; if ( !is_user_logged_in() &&

我想在用户访问我网站中的特定URL时执行一些操作

    add_action('template_redirect', 'woocommerce_custom_redirections');
    function woocommerce_custom_redirections() {
    $MyLoginURL = "https://example.com/?login=true&page=4";
    if ( !is_user_logged_in() && is_checkout() )
        wp_redirect($MyLoginURL);
    /*i want to change "is_account_page()" with "$MyLoginURL" in the line below*/
    if( is_user_logged_in() && is_account_page() )
        wp_redirect( get_permalink( get_option('woocommerce_checkout_page_id') ) );
}
如何将条件语句与特定URL(在本例中为“$MyLoginURL”)一起使用

注意:代码上的注释显示了问题。
任何帮助都将不胜感激。

获取当前页面url:

if(isset($_SERVER['HTTPS']) && $_SERVER['HTTPS'] === 'on')   
     $url = "https://";   
else  
     $url = "http://";   
// Append the host(domain name, ip) to the URL.   
$url.= $_SERVER['HTTP_HOST'];   

// Append the requested resource location to the URL   
$url.= $_SERVER['REQUEST_URI'];    

echo $url;  

使用
$url
变量执行某些条件。

$link=(isset($\u SERVER['HTTPS'])和&$\u SERVER['HTTPS']==='on'?“HTTPS:“http”)。"://" . $_服务器['HTTP_HOST']$_服务器['REQUEST_URI'];//跟上潮流url@Bhavik加杰尔,非常感谢