Gravity forms are passed to a third party and redirected using wp_http ()

I am trying to get the severity form from my Wordpress site to serve as a login form for another application (CakePhp website). The form has two fields: username and password. I added a hook to submit the form to another application using gform_after_submission as follows:



    add_action( 'gform_after_submission_6', 'mysite_gform_after_submission', 10, 2 ); 

    function mysite_gform_after_submission( $entry, $form ) {

     $post_url = 'http://otherapplicationurl.com/login';

     $body = array(
            "data[User][username]" => $entry[1], 
            "data[User][password]" => $entry[2], 
     );

        $request = new WP_Http();
        $response = $request->post($post_url, array('body' => $body));
    //this is to delete the entry

    GFAPI::delete_entry( $entry['id'] );
    }


Configure form confirmation - display some text. But what I essentially want to do is sign in with another application and show the home page of that application, that is, redirect to the URL " http://otherapplicationurl.com/home ".

I keep getting the following error.


    WP_Error Object
    (
        [errors] => Array
            (
                [http_request_failed] => Array
                    (
                        [0] => Too many redirects.
                    )

            )

        [error_data] => Array()

    )

, .

.

+4
1

. , , :

, . :

.. , cookie/session, , , . / ​​ /.

, , . , . ( , ), cookie. cookie , , .

1: ,

, . , URL-, http://otherapplication.com/login?user=adomnom&pass=awesome ( ).

2: , ( )

, , , . , "" , . . .

, - , cookie, .

...

1. CakePHP:/get-token

GET, , .

2. / CakePHP, GET 'token'

'token' to/login , .

3. ,

, gform_confirmation. , (.. , ).

add_action( 'gform_confirmation_6', 'mysite_gform_confirmation', 10, 3 ); 

function mysite_gform_confirmation( $confirmation, $form, $entry ) {

    // Send login request
    $token = wp_remote_post(
        'http://otherapplicationurl.com/login',
        array(
            'body' => array(
                "data[User][username]" => $entry[1], 
                "data[User][password]" => $entry[2]
            )
        )
    );

    // Delete entry
    GFAPI::delete_entry( $entry['id'] );

    // Redirect
    return array('redirect', "http://otherapplicationurl.com/login?token=$token");
}

, ! !

+2

All Articles