• Hi!

    I have a multiselect dropdown with different options and raw values, like this:

    [select* lloc id:lloc multiple include_blank “Option 1|a” “Option 2|b” “Option 3|c”]

    When I send an email including multiple values and raw values, like this:

    [lloc] – [raw_lloc]

    I obtain this:
    a b c – Option 1 Option 2 Option 3

    Anyway I could obtain this?:
    a – Option 1
    b – Option 2
    c – Option 3

    I would thank very much any help or link to a possible solution.

    • This topic was modified 3 years, 6 months ago by vanessavv04.
Viewing 3 replies - 1 through 3 (of 3 total)
  • Thread Starter vanessavv04

    (@vanessavv04)

    Thank you for your message.

    This is to save the correlative values in the database, but I need them in the email that the person receives from contact form 7, because I want to use it as a link. For example, if the user selects option 1 and 3, he should get something like this:

    <a href="a">Option 1</a>
    <a href="c">Option 3</a>

    But now the email shows the information like this:
    <a href="a c">Option 1 Option 3</a>

    Any idea? Is it possible?

    Thank you very much again

    • This reply was modified 3 years, 5 months ago by vanessavv04.

    my idea (not tested) is to hack the submitted data with and with the hook “wpcf7_before_send_mail”, so while submitting add or replace a string into emails model.

    // Get the submitted data
    $submission = WPCF7_Submission::get_instance();
    
    if ( ! $submission
         or ! $posted_data = $submission->get_posted_data() ) {
    	return;
    }
    
    // Get the contact form additional data
    $contact_form = $submission->get_contact_form();
    
    // get the tag used in the form
    $mail_tags=$contact_form->scan_form_tags();
    
    // search into tags for country
    $key = array_search('lloc', array_column($mail_tags, 'name'));
    
    // get the country pipes values
    $pipes = new WPCF7_Pipes( $mail_tags[$key]->raw_values );
    
    // get an array with the pipes
    $pipes_array = $pipes->to_array();
    error_log(print_r($pipes_array,true));

    in the pipes array you find all the select items

    // get the chosen value, loop into $posted_data['lloc'] as $i
    $pipes_val = array_search( $posted_data['lloc'][$i], array_column($pipes_array, 1));
    
    error_log(print_r($posted_data['lloc'][$i],true));
    error_log(print_r("in",true));
    error_log(print_r($pipes_array[$pipes_val][$i],true));

    I know it’s a crap but can’t find a native method to get those data and it’s the best idea I’ve had! let me know if it was helpful

Viewing 3 replies - 1 through 3 (of 3 total)
  • The topic ‘Separate values and raw values in multiselect dropdown’ is closed to new replies.