How to use api_request_url filter
-
Im trying to do something like this https://github.com/woocommerce/woocommerce/issues/10040
but since the filter api_request_url exist now im trying to use it.
I cant figure what i have to do although.
I have read about filters here: https://wpcandy.com/teaches/how-to-use-wordpress-hooks/ , i know i can put them in functions.php in the way it is described here: https://hookr.io/plugins/woocommerce/2.6.4/filters/woocommerce_api_request_url/
but what exactly i have to enter on the code of the filter?All i want to do is something like this
if (function_exists(‘pll_current_language’))
if (pll_current_language() == ‘en’)
$api_request_url = trailingslashit( home_url( ‘/index.php/wc-api/’ . $request, $scheme ) );with request being ‘en’.
so what am i missing? what i have to enter here to make it work?
// define the woocommerce_api_request_url callback?
function filter_woocommerce_api_request_url( $api_request_url, $request, $ssl ) {?
// make filter magic happen here…?
return $api_request_url;?
};?
?
// add the filter?
add_filter( ‘woocommerce_api_request_url’, ‘filter_woocommerce_api_request_url’, 10, 3 );thanks
- The topic ‘How to use api_request_url filter’ is closed to new replies.