Thank you @amimulihsanmahdi
I have created a function that will do what I would like.
For others to use as they would see fit.
// Create a custom shortcode to handle dynamic form embedding
// USE: [dynamic_fluentform id="11" ebook="my-ebook-slug"]
function dynamic_fluentform_shortcode($atts) {
// Extract attributes passed to the shortcode
$atts = shortcode_atts(array(
'id' => '', // FluentForm ID
'ebook' => '' // The dynamic eBook value or any custom param
), $atts, 'dynamic_fluentform');
// Sanitize values (always sanitize user inputs/attributes)
$form_id = intval($atts['id']);
$ebook_id = sanitize_text_field($atts['ebook']);
// Generate the FluentForm shortcode with dynamic hidden field value
$output = do_shortcode('[fluentform id="' . $form_id . '"]');
// Inject the hidden field value into the form using JS if necessary
$output .= "<script>
document.addEventListener('DOMContentLoaded', function() {
var ebookField = document.querySelector('input[name=\"ebook_id\"]');
if(ebookField) {
ebookField.value = '" . esc_js($ebook_id) . "';
}
});
</script>";
return $output;
}
// Register the custom shortcode
add_shortcode('dynamic_fluentform', 'dynamic_fluentform_shortcode');