Hi guys,
I currently have a requirement to insert shortcodes into a text field because each entry's shortcode needs modification.
Through a Google search, I found that ACF has a solution. The code is as follows:
<?php function my_acf_format_value( $value, $post_id, $field ) {
// Render shortcodes in all textarea values.
return do_shortcode( $value );
}
// Apply to all fields.
// add_filter('acf/format_value', 'my_acf_format_value', 10, 3);
// Apply to textarea fields.
add_filter('acf/format_value/type=textarea', 'my_acf_format_value', 10, 3);
How can I modify this code to allow the shortcode in Formidable text field, instead of being restricted to HTML field?
But I have limited programming experience, I need your assistance.
Thanks much,
Steven
What has ACF got to do with your question? You're asking about Formidable and providing an example of an ACF hook. You use shortcodes as default values in Formidable. https://formidableforms.com/knowledgebase/using-dynamic-default-values-in-fields/
Thank you for your response. I would like to clarify my question because I want to add a shortcode to a text field, and the value for each entry is different. The Formidable support team suggested using the frm_setup_new_fields_vars hook. I won't follow ACF's approach; I'm just referencing it. The following is the code I attempted to write, but it has no effect.
function my_custom_shortcode_setup( $field, $values ) { if ( $field['id'] == 355 ) { $field_value = $values['default_value']; $field_value_with_shortcode = do_shortcode( $field_value ); $values['default_value'] = $field_value_with_shortcode; } return $values; } add_filter( 'frm_setup_new_fields_vars', 'my_custom_shortcode_setup', 20, 2 );
Shortcode: [frm-pdf view=566 label="Download" entry_id="3582"]
Is there anyone who can help me take a look at where I went wrong?
Thanks,
Steven
What do you want the result to be? Are you trying to display a link or button for someone to download a pdf? Why use a text field?
What you are doing is downloading the entire output from the view to be displayed in a text field. Not only is that the wrong way to do it, but I really don't understand the logic it. Please explain what the outcome is supposed to be.
Please login or Register to submit your answer