Hey guys :) Happy Saturday! Could someone please tell me how to make this following bit applicable to form with ID of 17 only?
Tried a few bits and nothing seems to be working:
add_filter( 'frm_api_request_args', 'my_custom_frm_api_request_header_getstock', 10, 2 );
function my_custom_frm_api_request_header_getstock( $arg_array, $args ) {
if ( $args['url'] == 'https://api.xxx.com ) {
$arg_array['headers']['Host'] = 'api.xxx.com';
$arg_array['headers']['Content-type'] = 'application/json';
$arg_array['headers']['Accept'] = 'application/json';
$arg_array['headers']['Accept-Charset'] = 'utf-8';
$arg_array['headers']['Authorization'] = 'Bearer eyJmkdsoiuh....';
}
return $arg_array;
}
Thank you so much!
I think neither does, do you know how to add it in somehow from globally?
I just want to confirm. You used Kint or one of the PHP dump commands and examined the full content of the parameters and you don't recognize any element that refers to form ID. Is that correct?
I looked at the source code for FrmAPIAppController.php, which is where the frm_api_request_args filter fires in the private prepare_args method. The same array is passed as both filter arguments. The second parameter is for backward compatibility. The array is an associative array:
$args = array(
'url' => $url,
'headers' => $headers,
'body' => $body,
'method' => $method,
'timeout' => self::$timeout,
);
Based on what I'm seeing without reverse engineering code, form id may be in the body or url. Since this is a private class, it is not accessible to a developer even through polymorphism. The private keyword ensures that the declared property/method can only be accessed within the very class in which it is defined (the advantage of private methods/properties). However, the major drawback of using private (if not used correctly) is that child classes cannot inherit such properties/methods at all.
What this means is that of form id isn't in one of the other argument dimensions, you're out of luck. What you may be able to do is use a WordPress conditional is_page() to execute the function only for the page where the form is embedded.
Please login or Register to submit your answer