I am trying to get country name from country drop down, where I have used pipe symbol. like this in my form
[text* FullName id:fullname]
[select* country id:country include_blank "United States | [email protected]" "Canada | [email protected]" "Mexico | [email protected]" "United Kingdom | [email protected]"]
I have used different-2 email with country name because i need to sand email to company employee according to country name. In email template i have used [country]
to get email and [_raw_country]
to get country name that is working fine.
I am trying to get country name in function.php file to save it in database by this way.
function contactform7_before_send_mail( $form_to_DB ) {
//set your db details
$mydb = new wpdb('user','password','databasename','localhost');
$form_to_DB = WPCF7_Submission::get_instance();
if ( $form_to_DB )
$formData = $form_to_DB->get_posted_data();
$fullname = $formData['FullName'];
$country = $formData['country'];
$mydb->insert( 'mytable', array( 'fullname' =>$fullname,'country' =>$country), array( '%s' ) );
}
But it gives nothing. if i try to get like this
$country = $formData['country'][0];
it gives me only email id like [email protected] I have tryed $country = $formData['country'][1];
It give me nothing. I have also tryed $country = $formData['_raw_country'];
But not get luck.
This is the reference document
https://contactform7.com/selectable-recipient-with-pipes/
2
Answers
you need something like this:
I posted this answer in your other question. This should work.