0

既存の PHP ポータル (www.oureducation.in) があります。今、私はワードプレスの回答テーマを www.oureducation.in/answers に統合していました。

ここで、次のことを行う必要があります-ユーザーがmysiteに登録するときに、wordpressにユーザーを登録します。これはトリガーを使用して行いました。- mysite からのみログインしてください。ユーザーが mysite にログインする場合、wordpress にもログインする必要があります。 - wordpress からログアウトすると、ユーザーは自分のサイトからもログアウトされます (まったく機能しません)。

私はそれを完全に台無しにしたと思います。だから私は最初から始めたいです。これらの統合を実行する方法を教えてください。

私はこのリンクを通過しました - http://codex.wordpress.org/Integrating_WordPress_with_Your_Website ですが、あまり役に立ちませんでした。

次のコードを wp テーマの functions.php に追加しました

add_action( 'setup_theme', 'wp_session_oureducation' );

function wp_session_oureducation() {
    global $wpdb;

if( !$current_user->data->ID ) {
        if( !empty ($_SESSION['User_id'] ) ) {
            $fetchidquery = "Select ID from $wpdb->users where user_email = '".$_SESSION['E-mail']."'";
            $thisuserid = $wpdb->get_row($fetchidquery);
            wp_set_current_user( $thisuserid->ID,'');
            $user_id = $thisuserid->ID; 
        }
    }
}

add_action( 'wp_head', 'wp_session_oureducation_head' );

function wp_session_oureducation_head() {
global $wpdb;
    if( !$current_user->data->ID ) {
         if( !empty ( $_SESSION['User_id'] ) ) {
             $fetchidquery = "Select ID from $wpdb->users where user_email = '".$_SESSION['E-mail']."'";
             $thisuserid = $wpdb->get_row( $fetchidquery );
             wp_set_current_user( $thisuserid->ID,'');
             $user_id = $thisuserid->ID; 
         }
    }
}

ありがとう

4

0 に答える 0