Php 正在检查网站中的用户访问特定url
我想在用户访问我网站中的特定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() &&
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加杰尔,非常感谢