2013-10-25 50 views
2

我在我的WordPress代码中找不到任何重定向URL,但每次完成注册表单时,它都会重新定向到主页。我需要在注册完成后更改重定向。我可以理解,下面的代码演示了这个技巧,但任何人都可以帮助我如何将重定向设置为来自下面的代码的URL和要替换的部分?与WP重定向相混淆

感谢

 if ('publish' == $status) { 
     wp_safe_redirect(add_query_arg('updated', 'true', get_permalink($campaign))); 
     exit(); 
    } elseif ('submit' == $action) { 
     $url = isset ($edd_options[ 'submit_page' ]) ? get_permalink($edd_options[ 'submit_page' ]) : get_permalink(); 

     $redirect = apply_filters('atcf_submit_campaign_success_redirect', add_query_arg(array('success' => 'true'), $url)); 
     wp_safe_redirect($redirect); 
     exit(); 
    } else { 
     wp_safe_redirect(add_query_arg('preview', 'true', get_permalink($campaign))); 
     exit(); 
    } 
} 
add_action('template_redirect', 'atcf_shortcode_submit_process'); 

/** 
* Redirect submit page if needed. 
* 
* @since Astoundify Crowdfunding 1.1 
* 
* @return void 
*/ 
function atcf_shortcode_submit_redirect() { 
    global $edd_options, $post; 

    if (! is_a($post, 'WP_Post')) 
     return; 

    if (! is_user_logged_in() && (isset($edd_options[ 'submit_page' ]) && $post->ID == $edd_options[ 'submit_page' ]) && isset ($edd_options[ 'atcf_settings_require_account' ])) { 
     $url = isset ($edd_options[ 'login_page' ]) ? get_permalink($edd_options[ 'login_page' ]) : home_url(); 
     $url = add_query_arg(array('redirect_to' => get_permalink($edd_options[ 'submit_page' ])), $url); 

     $redirect = apply_filters('atcf_require_account_redirect', $url); 

     wp_safe_redirect($redirect); 
     exit(); 
    } 
} 
add_action('template_redirect', 'atcf_shortcode_submit_redirect', 1); 

回答

0

您已经很多wp_safe_redirect功能。

一些在atcf_shortcode_submit_redirect()之外,一个在里面。

但是,我不确定是基于您的代码,外面的那些人与注册页面没有任何关系。所以你应该改变里面的那个。

,这就是第一$url变量:

$url = isset ($edd_options[ 'login_page' ]) ? get_permalink($edd_options[ 'login_page' ]) : home_url(); 

正如你可以看到,如果没有与login_page重定向URL名称之前保存的将是home_url()这是您的主页链接选项。

如果你wan't将用户重定向到登录页面,你最好去找到这个选项(相关插件/模板设置页面某处)和检查/填充该选项,否则改变home_url()到无论你想要什么本地URL(,例如"http://mywebsite/successful-page"

0

我不确定在看到整个代码之前插件(或主题)在内部工作,但我有点感觉。

wp_safe_redirect重定向到给定的url(字符串)。所以试着修补那个。保留副本并将wp_safe_redirect参数更改为'https://google.com'或其他。然后你会发现哪些条件语句触发并重定向到你的主页。

我认为atcf_shortcode_submit_redirect函数重定向谁没有登录到登录页面,所以它不会与您的问题相关。

1

我喜欢使用javascript document.location。 只写与内部功能单一参数的函数提供JavaScript代码脚本标记

function redirect($location) 
{ 
//inside the function place the script code 
} 
<script language="javascript" type="text/javascript"> 
    document.location = "here will be your local variable"; 
</script> 
0

我知道这是旧的文章,但如果其他人正在寻找答案,这里就是我所做的。

我能够通过更改$ redirect值成功将用户重定向到配置文件页面。但是,当用户注销时,它会停留在配置文件页面上并将登录/注册添加到该页面中?

不管怎么说,我安装了彼得的登录重定向和设置只有2个选择: “所有其他用户”注销URL设置为你想要 “后注册网址”这个设置后应该拿出该页面的任何页面成功注册