Hello,
I use the radio button feature with contact-form-7 plugin to let the user select among different email addresses. When I look to the page I see something like
o name1@email.com
o name2@email.com
Additional or instead of the email address I want to show the administrative function of someone like "President", "Treasurer" etc.
I tried already to alter the checkbox.php like
...
foreach ( (array) $tag->values as $key => $value ) {
$checked = false;
if ( $is_posted && ! empty( $post ) ) {
if ( $multiple && in_array( esc_sql( $value ), (array) $post ) )
$checked = true;
if ( ! $multiple && $post == esc_sql( $value ) )
$checked = true;
} else {
if ( in_array( $key + 1, (array) $defaults ) )
$checked = true;
}
if ( isset( $tag->labels[$key] ) )
$label = $tag->labels[$key];
else
$label = $value;
$item_atts = array(
'type' => $tag->basetype,
'name' => $tag->name . ( $multiple ? '[]' : '' ),
'value' => $value,
'checked' => $checked ? 'checked' : '',
'tabindex' => $tabindex ? $tabindex : '' );
$item_atts = wpcf7_format_atts( $item_atts );
if ( $label_first ) { // put label first, input last
$item = sprintf(
'<span class="wpcf7-list-item-label">%1$s</span> <input %2$s />',
esc_html( $label ), $item_atts );
} else {
$item = sprintf(
'<input %2$s /> <span class="wpcf7-list-item-label">%1$s</span>',
esc_html( $label ), $item_atts );
}
/* This is what I added
if ($key == 0) $wb = " (President)";
if ($key == 1) $wb = " (Treasure)";
if ($key == 2) $wb = " (Member)";*/
if ( $use_label_element )
$item = '<label>' . $item . '</label>';
/* I chnged here by adding the $wb */
$item = '<span class="wpcf7-list-item">' . $item . $wb . '</span>';
//$item = '<span class="wpcf7-list-item">' . $item . '</span>';
$html .= $item;
if ( false !== $tabindex )
$tabindex += 1;
}
This works fine and I get this result:
"Please select one of the following email addresses to sent your post
o xxx@xxx.org (President)
o yyy@yyy.org (Treasure)"
But when I submit the form I get this error:
"Failed to send your message. Please try later or contact the administrator by another method."
I guess it is because the php took the whole line "xxx@xxx.org (President)" as the email address and this causes the failure.
How can I achieve that only the mail address is taken from the line?