I use a hook from the plugin Formidable Pro (frm_to_email
) where I absolutely need to have the ID of the current page (for Advanced Custom Fields). As the code is located in function.php
, it seems impossible for me to retrieve it. What can I do to get this value?
function custom_set_email_value($recipients, $values, $form_id, $args){
global $post;
$profil_obj = get_field('profil_obj', $post->ID); // If I put the ID directly (10 for example), it works
if( $form_id == get_field('popup_form_id', 'option') && $args['email_key'] == get_field('popup_email_id', 'option') ){
if($profil_obj) {
foreach( $profil_obj as $post) {
setup_postdata($post);
$recipients[] = get_field('profil_email', $post->ID);
}
}
wp_reset_postdata();
}
return $recipients;
}
add_filter('frm_to_email', 'custom_set_email_value', 10, 4);