• Hi great plugin!

    I have been pulling info from a custom textbox field of a custom post type to send some additional information in a email.

    Recently we changes the custom textfield in the Edit Post page to a dropbox with various options.

    When I put it like this: [dynamichidden dynamichidden-525 “CF7_get_custom_field key=’property_owner'”]
    It grabs the numeric postid of the item in the dropbox, but the idea is to give the textvalue that is in the dropbox (witch is the title of another custom post type).

    The code of the dropbox inside the costum post type is the following:

    if( !function_exists('ownerestate_box') ):
    function ownerestate_box($post) {
        global $post;
        wp_nonce_field(plugin_basename(__FILE__), 'owner_property_noncename');
    
        $mypost         =   $post->ID;
        $originalpost   =   $post;
        $owner_list     =   '';
        $picked_owner   =   (get_post_meta($mypost, 'property_owner', true));
    
        $args = array(
           'post_type'      => 'estate_owner',
           'post_status'    => 'publish',
           'posts_per_page' => -1
           );
    
         $owner_selection  =  new WP_Query($args);
    
         while ($owner_selection->have_posts()){
               $owner_selection->the_post();
               $the_id       =  get_the_ID();
    
               $owner_list  .=  '<option value="' . $the_id . '"  ';
               if ($the_id == $picked_owner) {
                   $owner_list.=' selected="selected" ';
               }
               $owner_list.= '>' . get_the_title() . '</option>';
          }
    
          wp_reset_postdata();
          $post = $originalpost;
    
          print '
          <label for="property_zip">'.__('Proprietário Responsável: ','wpestate').'</label><br />
          <select id="property_owner" style="width: 237px;" name="property_owner">
                <option value="">none</option>
                <option value=""></option>
                '. $owner_list .'
          </select>';
    }
    endif;

    https://www.ads-software.com/plugins/contact-form-7-dynamic-text-extension/

Viewing 4 replies - 1 through 4 (of 4 total)
  • Thread Starter vipete

    (@vipete)

    So it is putting out $the_id but I would like it to put out get_the_title() .

    Anyone an idea how I resolve this?

    Thread Starter vipete

    (@vipete)

    So I recon that I should add a shortcode in the “contact-form-7-dynamic-text-extension.php”

    function ownerestate_box($post) {
        global $post;
        wp_nonce_field(plugin_basename(__FILE__), 'owner_property_noncename');
    
        $mypost         =   $post->ID;
        $originalpost   =   $post;
        $owner_list     =   '';
        $picked_owner   =   (get_post_meta($mypost, 'property_owner', true));
    
        $args = array(
           'post_type'      => 'estate_owner',
           'post_status'    => 'publish',
           'posts_per_page' => -1
           );
    
         $owner_selection  =  new WP_Query($args);
    
         while ($owner_selection->have_posts()){
               $owner_selection->the_post();
               $the_id       =  get_the_ID();
    
               $owner_list  .=  '<option value="' . $the_id . '"  ';
               if ($the_id == $picked_owner) {
                   $owner_list.=' selected="selected" ';
               }
               $owner_list.= '>' . get_the_title() . '</option>';
          }
    add_shortcode('CF7_ownerestate_box', 'cf7_ownerestate_box');

    Something like this ? Any tips?

    Thread Starter vipete

    (@vipete)

    function cf7_get_custom_field($atts){
    	extract(shortcode_atts(array(
    		'key' => '',
    		'post_id' => -1,
    		'obfuscate'	=> 'off'
    	), $atts));
    
    	if($post_id < 0){
    		global $post;
    		if(isset($post)) $post_id = $post->ID;
    	}
    
    	if($post_id < 0 || empty($key)) return '';
    
    	$val = get_post_meta($post_id, $key, true);
    
    	if($obfuscate == 'on'){
    		$val = cf7dtx_obfuscate($val);
    	}
    
    	return $val;
    
    }
    add_shortcode('CF7_get_custom_field', 'cf7_get_custom_field');

    Actually I think I should add get_the_title() to this function somewhere, anyone know where to put this?

    Hello,

    I have site and I used CF7 not only once.At my homepage I have one CF7 that visitors can input at fields and I want it to pass to my second CF7 which is longer form than first but have the same field to the first CF7.In short,I want the fields from the first form need to be pre-filled into the second, longer form.

    Thanks in Advance!!

Viewing 4 replies - 1 through 4 (of 4 total)
  • The topic ‘CF7_get_custom_field value from dropbox gets number value instead of text’ is closed to new replies.