• Resolved surrealillusions

    (@surrealillusions)


    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.

    http://wordpress.org/extend/plugins/contact-form-7/

Viewing 2 replies - 1 through 2 (of 2 total)
  • Thread Starter surrealillusions

    (@surrealillusions)

    Ok, I think I have it almost sorted. Got a dropdrown select box that is populated with custom field content.

    But, it only sends one value when more than one is selected, and it is a multiple select box – any ideas on what the problem is there?

    DOCSpeedFreak

    (@docspeedfreak)

    Hi surrealillusions,

    would you be so kind to post your code for the dropdown? I´m searching for a solution to fill checkboxes with data from a custom field…

    Thx in advance

Viewing 2 replies - 1 through 2 (of 2 total)

The topic ‘[Plugin: Contact Form 7] Adding dynamic dropdrowns or checkboxes’ is closed to new replies.