How can i set a CF7 input field default value with a shortcode?
-
I have made a simple shortcode which returns the value of a column from a custom db table
`function helper_set_prefilled_value($atts){
extract(shortcode_atts(array(
‘column’ => ‘phone’,
), $atts));global $current_user;
if (is_user_logged_in()) {
$wp_id = $current_user->ID;if (helper_first_time_here() == FALSE) {
$values_from_db = UserData::get_column_form_data($column, $wp_id);
return $values_from_db;
}
}
}
add_shortcode(‘shortcode_prefilled_value exhibitor’ , ‘helper_set_prefilled_value’);`But when i tried the
` <p>First Name (required)<br />[shortcode_prefilled_value exhibitor column=first_name]
[text first_name “[shortcode_prefilled_value exhibitor column=first_name]”] </p>`the shortcode doesn’t work for the input field. It does work after the
tagbtw i added
` function wpcf7_form_elements($form) {
$form = do_shortcode($form);
return $form;
}add_filter(‘wpcf7_form_elements’, ‘wpcf7_form_elements’);`
so shortcodes will work in CF7 form
- The topic ‘How can i set a CF7 input field default value with a shortcode?’ is closed to new replies.