Home > Enterprise >  How to call a plugin outside of Wordpress?
How to call a plugin outside of Wordpress?

Time:12-24

So, I need to call a plugin from outside my woocommerce websites. I have my own database that connects to Woocommerce throught REST API when it comes to products, orders and etc. My problem is, now I need to call a plugin on admin.php?page=pluginName&action=action&orderid=123456.The server that communicates with woocommerce is using classic ASP. I already tried to simply do a POST but of course wordpress asks me for login. I even tried to post it to a custom php page inside woocommerce and then post it to the plugin page but no success. Is there any way to call the plugin URL without having to login every time? It can be a php code inside my woocommerce FTP that recieves a POST with the order ID (the only query string that changes on each recordet) and then makes an AJAX POST to the plugin or something

Tried to create a custom PHP code to retrieve the POST and then do a wp_remote_post to the admin.php URL but nothing works. I just need to run the url, the plugin does the rest then

CodePudding user response:

WordPress plugins rely on a lot of WordPress core code to function. Getting them to stand alone will be a LOT of work and your result will be brittle if you can get it to work at all. (Brittle === anything might break it, including a core or plugin update.)

WordPress's REST API is the best way to access WordPress, including plugin functionality, from some other network server. WooCommerce also supports REST, documented here. It offers an API key subsystem allowing secure authentication.

It's a programming task, but not unreasonably hard, to write a small plugin that adds a REST endpoint or two for a special purpose. But it's possible the one of the existing WooCommerce REST endpoints will serve your purpose. (You didn't tell us what it is, so it's hard to give more detailed advice.)

CodePudding user response:

How about using this plugin? https://wordpress.org/plugins/ip-based-login/

This will allow you to skip login for request that comes from specified IPs.

I would personally go with the custom rest endpoint but this approach could work for your use case too.

  • Related