[Plugin: Contact Form 7] Adding dynamic dropdrowns or checkboxes
-
Hey everyone,
I’d like to know how to create a dynamically generated dropdrown selection box, or checkboxes, based upon some values inside a custom field from the WP page or post.
I’m aware of the dynamic cf7 input text plugin, but that only deals with text fields. However, is it possible to generate your own shortcut code for use within CF7 that has pulled in information from the custom field.
Setup would be ideally as follows:
Admin user enters some values into a custom field, separated by spaces with values encased with double quotes “, like the select dropdrown box from CF7.
“value one” “value two” “something else” etc…The post template puts them into an array, and then creates a shortcut code for CF7 like [customselect nameofdropdrown] or something so I can put that into a general form which can be used on several pages, but with different dropdrown options.
I have this for displaying custom field values:
// Get Custom Field Template Values function getCustomField($theField) { global $post; $block = get_post_meta($post->ID, $theField); if($block){ foreach(($block) as $blocks) { echo $blocks; } } } /* Then use this to display the fields in the theme: <?php getCustomField('customfieldname'); ?> */Which is in the functions.php file, but that displays the value, so I can’t do anything else with it. Unless I change the echo $blocks; to return $blocks; will that do the trick?
Thanks.
The topic ‘[Plugin: Contact Form 7] Adding dynamic dropdrowns or checkboxes’ is closed to new replies.