'user_login', 'default:user_email' => 'user_email', 'default:user_url' => 'user_url', 'default:user_first_name' => 'first_name', 'default:user_last_name' => 'last_name', 'default:user_nickname' => 'nickname', 'default:user_display_name' => 'display_name' ); foreach ( $user_options as $option => $prop ) { if ( preg_grep( '%^' . $option . '$%', $options ) ) { $value = $user->{$prop}; break; } } } if ( wpcf7_is_posted() && isset( $_POST[$name] ) ) $value = stripslashes_deep( $_POST[$name] ); if ( $id_att ) $atts .= ' id="' . trim( $id_att ) . '"'; if ( $class_att ) $atts .= ' class="' . trim( $class_att ) . '"'; if ( $size_att ) $atts .= ' size="' . $size_att . '"'; else $atts .= ' size="40"'; // default size if ( $maxlength_att ) $atts .= ' maxlength="' . $maxlength_att . '"'; if ( '' !== $tabindex_att ) $atts .= sprintf( ' tabindex="%d"', $tabindex_att ); if ( $title_att ) $atts .= sprintf( ' title="%s"', trim( esc_attr( $title_att ) ) ); $html = ''; $html = '' . $html . $validation_error . ''; return $html; } /* Validation filter */ add_filter( 'wpcf7_validate_text', 'wpcf7_text_validation_filter', 10, 2 ); add_filter( 'wpcf7_validate_text*', 'wpcf7_text_validation_filter', 10, 2 ); add_filter( 'wpcf7_validate_email', 'wpcf7_text_validation_filter', 10, 2 ); add_filter( 'wpcf7_validate_email*', 'wpcf7_text_validation_filter', 10, 2 ); function wpcf7_text_validation_filter( $result, $tag ) { $type = $tag['type']; $name = $tag['name']; $_POST[$name] = trim( strtr( (string) $_POST[$name], "\n", " " ) ); if ( 'text*' == $type ) { if ( '' == $_POST[$name] ) { $result['valid'] = false; $result['reason'][$name] = wpcf7_get_message( 'invalid_required' ); } } if ( 'email' == $type || 'email*' == $type ) { if ( 'email*' == $type && '' == $_POST[$name] ) { $result['valid'] = false; $result['reason'][$name] = wpcf7_get_message( 'invalid_required' ); } elseif ( '' != $_POST[$name] && ! is_email( $_POST[$name] ) ) { $result['valid'] = false; $result['reason'][$name] = wpcf7_get_message( 'invalid_email' ); } } return $result; } /* Tag generator */ add_action( 'admin_init', 'wpcf7_add_tag_generator_text_and_email', 15 ); function wpcf7_add_tag_generator_text_and_email() { wpcf7_add_tag_generator( 'text', __( 'Text field', 'wpcf7' ), 'wpcf7-tg-pane-text', 'wpcf7_tg_pane_text' ); wpcf7_add_tag_generator( 'email', __( 'Email field', 'wpcf7' ), 'wpcf7-tg-pane-email', 'wpcf7_tg_pane_email' ); } function wpcf7_tg_pane_text( &$contact_form ) { wpcf7_tg_pane_text_and_email( 'text' ); } function wpcf7_tg_pane_email( &$contact_form ) { wpcf7_tg_pane_text_and_email( 'email' ); } function wpcf7_tg_pane_text_and_email( $type = 'text' ) { if ( 'email' != $type ) $type = 'text'; ?>