Insert variable in shortcode

Formidable Forms
27 February, 2022 19:00:06
NTR
Topics: 2
Messages: 3
I'm trying to run a shortcode in my theme's single post page (single.php). Trying to set the dataset parameter to an entry ID which is stored in a post custom field. Following is my code:

<?php
$form_id = get_post_meta($post->ID, 'entry_ID' , true);
echo do_shortcode('[e2pdf-download id="3" button-title="Download the Proposal" dataset="' . $form_id . '"]');
?>

However, this is not working. The shortcode does work when I use a static entry ID number rather than the $form_id variable for dataset. Any suggestion how to get dataset variable to work?
27 February, 2022 23:19:12
E2Pdf
Support
Topics: 7
Messages: 3330
Hi,

The shortcode looks okay however are you sure that form_id returns correct Entry ID and not Form ID? Can you check please with.

Can you check please which value you get via var_dump? as:

$form_id = get_post_meta($post->ID, 'entry_ID' , true);
var_dump($form_id);
die();


We would really appreciate your feedback at WordPress.org!
28 February, 2022 07:08:00
NTR
Topics: 2
Messages: 3
The Entry ID stored in the variable was correct. However, I somehow missed in the shortcode that it should be id=2 rather than id=3. Was using the wrong pdf. It now displays the download link correctly in my theme. Thank you for your assistance! Excellent product.