WordPress.org

Ready to get started?Download WordPress

Forums

Outbound Requests Fail After plugins_loaded Triggered (1 post)

  1. Jonah Bron
    Member
    Posted 1 year ago #

    Hello, world!

    There is an interesting problem on my site that has left me quite baffled, and I hoped one of you might know what the problem is.

    In short, if I don't put a HTTP request to any remote server before the 'plugins_loaded' action is triggered, remote requests don't work in WP E-Commerce. I tried both cURL, wp_remote_post, and file_get_contents().

    The long version:

    My site processes credit cards through Authorize.net, with the WP E-Commerce plugin. Unfortunately, the request to Authorize.net fails with the error "Couldn't resolve host 'secure.authorize.net'". I tried creating another script on the same host to execute the same request, and it worked. I tried putting the request in WordPresses index.php, and it worked from there.

    However, something interesting happened when I made a request in index.php before WordPress was loaded. The request in the plugin worked! I removed it, the plugin request failed. I figured out that simply putting in a file_get_contents() call to any remote HTTP server caused the plugin request to magically work.

    After working my way down the stack to figure out where the problem was starting, I came down to the 'plugins_loaded' action. If I placed the file_get_contents() in the same scope as the 'plugins_loaded' action registration call in the plugin, the request worked. Putting it into the function that 'plugins_loaded' called resulted in both of them failing.

    It seems that the difference between the payment processing working and not working is placing a HTTP request to any remote HTTP server before 'plugins_loaded' is triggered.

    Why in the world would that happen? And why does a request before that action make it work? I'm quite confused.

    Thank you!

Topic Closed

This topic has been closed to new replies.

About this Topic