• function dynamic_select_field_values ( $scanned_tag, $replace ) { 
    	//Si il y a un pilote
    	if( isset ($_SESSION["pilote"]) AND !empty($_SESSION["pilote"]) ){ 
    	$current_pilote=$_SESSION["pilote"];	
        if($scanned_tag['name'] != 'aile') return $scanned_tag;	
        $rows = get_posts(
        array ( 
    	'post_type' => $current_pilote,  
    	'numberposts' => -1,  
    	'orderby' => 'title',  
    	'order' => 'ASC' 
        )
        );	
        if(!$rows) return $scanned_tag;	
        foreach($rows as $row) {  
         $scanned_tag['raw_values'][] = $row->post_title . '|' . $row->post_title;	
        }
        $pipes = new WPCF7_Pipes($scanned_tag['raw_values']);
        $scanned_tag['values'] = $pipes->collect_befores();
        $scanned_tag['pipes'] = $pipes;
        return $scanned_tag;  
    	}
    	
    	//Si il n'y a pas de pilote
    	$current_pilote="nc";	
        if($scanned_tag['name'] != 'aile') return $scanned_tag;	
        $rows = get_posts(
        array ( 
    	'post_type' => $current_pilote,  
    	'numberposts' => -1,  
    	'orderby' => 'title',  
    	'order' => 'ASC' 
        )
        );	
        if(!$rows) return $scanned_tag;	
        foreach($rows as $row) {  
         $scanned_tag['raw_values'][] = $row->post_title . '|' . $row->post_title;	
        }
        $pipes = new WPCF7_Pipes($scanned_tag['raw_values']);
        $scanned_tag['values'] = $pipes->collect_befores();
        $scanned_tag['pipes'] = $pipes;
        return $scanned_tag;  
    }  
    add_filter( 'wpcf7_form_tag', 'dynamic_select_field_values', 10, 2);

    Hello Contact Form 7 specialists,
    since 5.9 update this code doesn’t work any more!
    $current_pilote=$_SESSION[“pilote”]; seems to be the issue.
    if I use $current_pilote=”jack”;
    it works like before but that’s not what I want….
    Help !
    (mean time I backed up to 5.8.7 in order to be able to keep using my website)
    Thanks
    Jacques from Grenoble France

    The page I need help with: [log in to see the link]

Viewing 1 replies (of 1 total)
  • Thread Starter jackbluehouse2019

    (@jackbluehouse2019)

    here is a simplified version of the code which no longer works with the latest CF7 update

    
    function dynamic_select_field_values($scanned_tag, $replace) {
        global $current_user;
        $current_user = wp_get_current_user();
        $current_pilote = $current_user->user_login;
    	
    	 //$current_pilote ='plugin2024';
    
        if ($scanned_tag['name'] != 'menu_913') 
            return $scanned_tag;
    
        $rows = get_posts(
            array (
                'post_type'    => $current_pilote,
                'numberposts'  => -1,
                'orderby'      => 'title',
                'order'        => 'ASC',
            )
        );
    
        if (!$rows) 
            return $scanned_tag;
    
        foreach ($rows as $row) {
            $scanned_tag['raw_values'][] = $row->post_title;
        }
    
        $scanned_tag['values'] = $scanned_tag['raw_values'];
    
        return $scanned_tag;
    }
    add_filter('wpcf7_form_tag', 'dynamic_select_field_values', 10, 2);

    the code does not work if I use $current_pilote = $current_user->user_login;
    on the other hand if I use: $current_pilote =’plugin2024′;
    the code works.
    plugin2024 is the user login

Viewing 1 replies (of 1 total)
  • The topic ‘wpc7_form_tag’ is closed to new replies.