2

WordPress コードにリダイレクト URL が見つかりませんでしたが、登録フォームを完了するたびにホームページに再度リダイレクトされます。登録が完了したら、リダイレクトを変更する必要があります。次のコードがトリックを実行することは理解できますが、次のコードから URL へのリダイレクトを設定する方法と、どの部分を置き換えるかを教えてもらえますか?

ありがとう

        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 );
4

4 に答える 4

0

コード全体を見る前に、プラグイン (またはテーマ) が内部的に機能するかどうかはわかりませんが、少しは理解できます。

wp_safe_redirect は、指定された url(string) にリダイレクトします。それで、それをいじってみてください。コピーしたまま wp_safe_redirect パラメータを「https://google.com」などに変更します。次に、どの条件ステートメントがトリガーされ、ホームページにリダイレクトされているかがわかります。

atcf_shortcode_submit_redirect 関数は、ログインしていない人をログイン ページにリダイレクトすると思うので、問題には関係ありません。

于 2013-10-25T12:50:24.953 に答える
0

これが古い投稿であることは知っていますが、他の誰かが答えを探している場合に備えて、私がしたことは次のとおりです。

$redirect 値を変更することで、ユーザーをプロファイル ページに正常にリダイレクトできました。ただし、ユーザーがログアウトすると、プロファイルページにとどまり、そのページにログイン/登録を追加します???

とにかく、Peter のログイン リダイレクトをインストールし、2 つのオプションのみを設定しました。「他のすべてのユーザー」は、ログアウト URL を任意のページに設定します。「登録後 URL」は、登録が成功した後に表示されるページに設定します。

于 2015-01-07T20:57:58.370 に答える
0

You've many wp_safe_redirect functions.

Some outside the atcf_shortcode_submit_redirect() and one inside of it.

However I'm not sure really based on your code, those outside don't have anything to do with registration page. So you should change the one that is inside.

and that's the first $url variable:

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

As you can see if there is no option saved before with the name of login_page redirection URL will be home_url() that's your homepage link.

If you wan't to redirect the user to login page, you'd better go and find this option (somewhere in related plugin/template settings page) and check/fill that option, otherwise change the home_url() to whatever local URL you want (e.g. "http://mywebsite/successful-page")

于 2013-10-25T12:47:05.777 に答える