Im trying to supply the post ID to a plugin function in the plugin file. But instead of the value, its NULL

TY for opening my question! Im trying to update the meta key ‘license’ in a custom post that I have, with the ID of an existing WP post. So Im using a global variable to store the ID of the WP post within the loop in the single.php file:

$GLOBALS[‘greenhorn’]= get_the_ID();

Now, I am trying to pass it to a function in a plugin, to update the meta as follows (I pasted my function, as underneath, in the functions.php of the child theme):

function the_some_meta_update( $post_id )

{
update_post_meta( $post_id, ‘license’, $greenhorn );
}

add_action(‘fes_submission_form_save_custom_fields’, ‘the_some_meta_update’, >10, 3);

The keen reader has figured that the hook name – add action was used to trigger the function each time a new custom post was created in a plugin to create these custom posts (EasyDigitalDownloads FES). I keep getting the value of the meta key ‘license’ as null at each attempt. Am I writing my hook wrong? or is my global variable malfunctioning?

These are the plugin instructions:
” This is for developers to add dynamic elements as they want. It provides the chance to add whatever input type you want to add in this form. You can bind your own functions to render the form to this action hook. You’ll be given 3 parameters to play with: $form_id, $post_id, $form_settings.
add_action(‘{hookname}’, ‘my_function_name}’, 10, 3 );
// first param: Form Object
// second param: Save ID of post/user/custom
// third param: Field Object
function my_function_name( $form, $save_id, $field ) {
// Do whatever you want here
}”

THANKS.

Read more here:: Im trying to supply the post ID to a plugin function in the plugin file. But instead of the value, its NULL

Leave a Reply

Your email address will not be published. Required fields are marked *