zaus / forms-3rdparty-integration

Wordpress Plugin - Forms 3rdparty Integration - a plugin to help integrate 3rdparty services with common WP Forms plugins like Contact Form 7 and Gravity Forms
http://wordpress.org/plugins/forms-3rdparty-integration/
47 stars 14 forks source link

Passing url response back #10

Closed mordant23 closed 10 years ago

mordant23 commented 10 years ago

I use a service which redirects a url based on whether it's successful or not, e.g. if successful user is sent to successURL and if unsuccessful the user is sent to errorURL. To keep the user on the page, I use a script based upon the query string of the url. The issue seems to be how to handle the redirect. Is there a way to pass the redirect to wordpress or is there some other way to look at the url sent back by the service?

zaus commented 10 years ago

Sorry for the delay. I think you'd need to read the headers from the response, which unfortunately I'm not including in the hook; is there a difference in the response content you could check against, rather than the URL?

mordant23 commented 10 years ago

My apologies, I figured out how to get what I needed to work. Basically I had to create a plugin which integrated with Gravity Forms and Forms: 3rd Party Integration. I'd have to look at the code, which is at work, more closely if you're interested in the details. Basically, part of the plugin was to provide both a success url and failure url by creating two files, success.php and error.php, within the plugin directory. The content of success.php, which was just the word "success", was used as the success condition.

I believe the reason I had to use this work around was because of how the WordPress HTTP API works. The helper function wp_remote_post returns an object which contains the contents of the redirected page instead of actually performing a redirect.

While my understanding of how the POST method actually interacts with a web server is limited, from what I could tell from the debugging reports, nothing in the header property of the returned object would have helped.

zaus commented 10 years ago

Glad you figured it out. I'd be interested in the plugin code, at least so if there's something there I can use to improve Forms-3rdparty to make your work easier.

Should I consider this resolved?

mordant23 commented 10 years ago

Yes, consider this resolved. I added a repository, ExactTarget-DEManager, which you can take a look at https://github.com/mordant23/ExactTarget-DEManager. If you have any questions, please ask. I'd probably code it differently now, but it works.