Captcha below custom submit button in Contact Form

resolved (12 posts) (5 voices)

  1. JanVanGorkum
    Member

    I'm creating a Wordpress website with the InFocus theme. While making a contact form, the captcha field appears below the custom submit button.

    I've read on this forum that putting [captcha] in the short code before [submit value="..."] should make it work, but that also doesn't work. Then there appears a second captcha field above the submit button, while the first captcha field remains below the submit button.

    Any suggestions how I can put the captcha field above the custom submit button?

    Posted 5 years ago #
  2. Elliott
    Support

    Hello JanVanGorkum,

    Send us a link to your page and we'll give you some CSS to use.

    Posted 5 years ago #
  3. Hi Was this ever solved?

    Thanks
    RTA

    Posted 4 years ago #
  4. Elliott
    Support

    Send us a link.

    Posted 4 years ago #
  5. Elliott
    Support

    Add this to your custom CSS,

    .captcha_row {
        position: relative;
        top: -70px;
    }
    .submit_row {
        position: relative;
        top: 60px;
    }
    Posted 4 years ago #
  6. Works perfect, thanks Elliot!

    Posted 4 years ago #
  7. Hi Elliot

    Only just noticed that the code has affected the captcah position on our contact us page: http://s315189846.websitehome.co.uk/r_talent/contact-us/

    Before adding the code that captcha was in the right place on the contact us page

    Thanks & Merry Christmas
    RTA

    Posted 4 years ago #
  8. Elliott
    Support

    Add it to the custom CSS field in whatever page you want to change it on instead of the custom CSS field in Dashboard -> your theme -> General Settings.

    Posted 4 years ago #
  9. Thanks Elliot

    RTA

    Posted 4 years ago #
  10. motionmanager
    Member

    I don't think this is a good solution. I changed /wp-content/themes/elegance/shortcodes/16-contact.php instead - starting from line 71:

    [code]for( $i = 0; $i < count($matches[0]); $i++ ) {

    if ($matches[1][$i] == 'submit') {

    $out_submit = '<div class="mysite_form_row ' . $matches[1][$i] . '_row' . '">';

    $field_id = 'mysite_field' . $i . $form_id;
    $matches[2][$i] = shortcode_parse_atts( $matches[2][$i] );

    if( isset( $errored_fields ) )
    $required_error = ( !in_array( $field_id, $errored_fields ) ) ? '' : ' required_error';

    $required = ( $matches[1][$i] == 'captcha' ? 'captcha'
    : ( empty( $matches[2][$i]['required'] ) ? false
    : ( $matches[1][$i] == 'email' ? 'email'
    : 'true'
    )));
    $label = ( !empty( $matches[2][$i]['label'] ) ) ? $matches[2][$i]['label'] : ' ';

    if( $required == 'captcha' ) {
    $num1 = rand(1,10);
    $num2 = rand(1,10);
    $label = $num1 .' + '. $num2 . ' ';
    }
    $out_submit .= '<label for="' . $field_id . '">' . $label;
    if( ( $required ) && ( $required != 'captcha' ) ) {
    $out_submit .= '<span class="star">*</span>';
    }
    $out_submit .= '</label>';

    if( $matches[1][$i] == 'textfield' || $matches[1][$i] == 'name' || $matches[1][$i] == 'email' || $required == 'captcha' ) {
    $out_submit .= '<input type="text" name="' . $field_id . '" id="' . $field_id . '" class="textfield' . $required_error .
    ( $matches[1][$i] != 'textfield' ? ' ' . $matches[1][$i] : '' ) . '' . ( $required ? ' required' : '' ) . '" value="' .
    ( isset( $_POST[$field_id] ) ? esc_attr( $_POST[$field_id] ) : '' ) . '" />';
    $form_inputs['fields'][$field_id] = array( 'type' => $matches[1][$i], 'label' => $label, 'required' => $required );

    if( $required == 'captcha' ) {
    $form_inputs['fields'][$field_id]['captcha'] = $num1+$num2;
    }
    }

    if( $matches[1][$i] == 'textarea' ) {
    $out_submit .= '<textarea name="' . $field_id . '" id="' . $field_id . '" class="textarea' . $required_error . ( $required ? ' required' : '' ) . '" rows="5" cols="40">' .
    ( isset( $_POST[$field_id] ) ? esc_attr( $_POST[$field_id] ) : '' ) . '</textarea>';
    $form_inputs['fields'][$field_id] = array( 'type' => $matches[1][$i], 'label' => $label, 'required' => $required );
    }

    if( $matches[1][$i] == 'checkbox' ) {
    $out_submit .= '<input type="checkbox" name="' . $field_id . '" id="' . $field_id . '" class="styled' . $required_error . ( $required ? ' required' : '' ) . '"' .
    ( isset( $_POST[$field_id] ) ? ' checked="checked"' : '' ) . ' value="1" />';
    $form_inputs['fields'][$field_id] = array( 'type' => $matches[1][$i], 'label' => $label, 'required' => $required );
    }

    if( $matches[1][$i] == 'radio' ) {
    if( !empty( $matches[2][$i]['value'] ) ) {
    $options = explode( ',', $matches[2][$i]['value'] );
    foreach( $options as $key => $value ) {
    $radio_id = $field_id . '_' . $key;
    $out_submit .= '<input type="radio" name="' . $field_id . '" id="' . $radio_id . '" class="styled' . $required_error . ( $required ? ' required': '' ) . '"' .
    ( !isset( $_POST[$field_id] ) ? ( $key == 0 ? ' checked="checked"' : '' ) : ( $_POST[$field_id] == $key ? ' checked="checked"' : '' ) ) . ' value="' . $key . '" />';
    $out_submit .= '<label for="' . $radio_id . '" class="radio_label">' . $value . '</label>';
    }
    $form_inputs['fields'][$field_id] = array( 'type' => $matches[1][$i], 'label' => $label, 'value' => $options, 'required' => $required );
    }
    }

    if( $matches[1][$i] == 'select' ) {
    if( !empty( $matches[2][$i]['value'] ) ) {
    $options = explode( ',', $matches[2][$i]['value'] );
    $out_submit .= '<select name="' . $field_id . '" id="' . $field_id . '" class="styled' . $required_error . ( $required ? ' required' : '' ) . '">';
    foreach( $options as $key => $value ) {
    $out_submit .= '<option value="' . $value . '"' .
    ( !isset( $_POST[$field_id] ) ? '' : ( $_POST[$field_id] == $value ? ' selected="selected"' : '' ) ) . '>' . $value . '</option>';
    }
    $out_submit .= '</select>';
    $form_inputs['fields'][$field_id] = array( 'type' => $matches[1][$i], 'label' => $label, 'required' => $required );
    }
    }

    $submit_button = true;
    $submit_value = ( !empty( $matches[2][$i]['value'] ) ) ? $matches[2][$i]['value'] : 'senden';
    $out_submit .= '<input type="submit" value="' . $submit_value . '" class="contact_form_submit fancy_button" />';

    $out_submit .= '<div class="mysite_contact_feedback">';
    $out_submit .= '<img src="' . esc_url( THEME_IMAGES_ASSETS . '/transparent.gif' ) . '" style="background-image: url(' . THEME_IMAGES_ASSETS . '/preloader.png);">';
    $out_submit .= '</div>';

    if( $matches[1][$i] == 'autoresponder' ) {
    $name = ( !empty( $matches[2][$i]['fromname'] ) ) ? $matches[2][$i]['fromname'] : get_bloginfo('name');
    $email = ( !empty( $matches[2][$i]['fromemail'] ) ) ? trim( $matches[2][$i]['fromemail'] ) : $form_inputs['mysite_email'];
    $subject = ( !empty( $matches[2][$i]['subject'] ) ) ? $matches[2][$i]['subject'] : false;
    $message = ( !empty( $matches[2][$i]['message'] ) ) ? $matches[2][$i]['message'] : false;
    $form_inputs['autoresponder'][] = array( 'name' => $name, 'email' => $email, 'subject' => $subject, 'message' => $message );
    }

    $out_submit .= '</div>';

    } else {

    $out .= '<div class="mysite_form_row ' . $matches[1][$i] . '_row' . '">';

    $field_id = 'mysite_field' . $i . $form_id;
    $matches[2][$i] = shortcode_parse_atts( $matches[2][$i] );

    if( isset( $errored_fields ) )
    $required_error = ( !in_array( $field_id, $errored_fields ) ) ? '' : ' required_error';

    $required = ( $matches[1][$i] == 'captcha' ? 'captcha'
    : ( empty( $matches[2][$i]['required'] ) ? false
    : ( $matches[1][$i] == 'email' ? 'email'
    : 'true'
    )));
    $label = ( !empty( $matches[2][$i]['label'] ) ) ? $matches[2][$i]['label'] : ' ';

    if( $required == 'captcha' ) {
    $num1 = rand(1,10);
    $num2 = rand(1,10);
    $label = $num1 .' + '. $num2 . ' ';
    }
    $out .= '<label for="' . $field_id . '">' . $label;
    if( ( $required ) && ( $required != 'captcha' ) ) {
    $out .= '<span class="star">*</span>';
    }
    $out .= '</label>';

    if( $matches[1][$i] == 'textfield' || $matches[1][$i] == 'name' || $matches[1][$i] == 'email' || $required == 'captcha' ) {
    $out .= '<input type="text" name="' . $field_id . '" id="' . $field_id . '" class="textfield' . $required_error .
    ( $matches[1][$i] != 'textfield' ? ' ' . $matches[1][$i] : '' ) . '' . ( $required ? ' required' : '' ) . '" value="' .
    ( isset( $_POST[$field_id] ) ? esc_attr( $_POST[$field_id] ) : '' ) . '" />';
    $form_inputs['fields'][$field_id] = array( 'type' => $matches[1][$i], 'label' => $label, 'required' => $required );

    if( $required == 'captcha' ) {
    $form_inputs['fields'][$field_id]['captcha'] = $num1+$num2;
    }
    }

    if( $matches[1][$i] == 'textarea' ) {
    $out .= '<textarea name="' . $field_id . '" id="' . $field_id . '" class="textarea' . $required_error . ( $required ? ' required' : '' ) . '" rows="5" cols="40">' .
    ( isset( $_POST[$field_id] ) ? esc_attr( $_POST[$field_id] ) : '' ) . '</textarea>';
    $form_inputs['fields'][$field_id] = array( 'type' => $matches[1][$i], 'label' => $label, 'required' => $required );
    }

    if( $matches[1][$i] == 'checkbox' ) {
    $out .= '<input type="checkbox" name="' . $field_id . '" id="' . $field_id . '" class="styled' . $required_error . ( $required ? ' required' : '' ) . '"' .
    ( isset( $_POST[$field_id] ) ? ' checked="checked"' : '' ) . ' value="1" />';
    $form_inputs['fields'][$field_id] = array( 'type' => $matches[1][$i], 'label' => $label, 'required' => $required );
    }

    if( $matches[1][$i] == 'radio' ) {
    if( !empty( $matches[2][$i]['value'] ) ) {
    $options = explode( ',', $matches[2][$i]['value'] );
    foreach( $options as $key => $value ) {
    $radio_id = $field_id . '_' . $key;
    $out .= '<input type="radio" name="' . $field_id . '" id="' . $radio_id . '" class="styled' . $required_error . ( $required ? ' required': '' ) . '"' .
    ( !isset( $_POST[$field_id] ) ? ( $key == 0 ? ' checked="checked"' : '' ) : ( $_POST[$field_id] == $key ? ' checked="checked"' : '' ) ) . ' value="' . $key . '" />';
    $out .= '<label for="' . $radio_id . '" class="radio_label">' . $value . '</label>';
    }
    $form_inputs['fields'][$field_id] = array( 'type' => $matches[1][$i], 'label' => $label, 'value' => $options, 'required' => $required );
    }
    }

    if( $matches[1][$i] == 'select' ) {
    if( !empty( $matches[2][$i]['value'] ) ) {
    $options = explode( ',', $matches[2][$i]['value'] );
    $out .= '<select name="' . $field_id . '" id="' . $field_id . '" class="styled' . $required_error . ( $required ? ' required' : '' ) . '">';
    foreach( $options as $key => $value ) {
    $out .= '<option value="' . $value . '"' .
    ( !isset( $_POST[$field_id] ) ? '' : ( $_POST[$field_id] == $value ? ' selected="selected"' : '' ) ) . '>' . $value . '</option>';
    }
    $out .= '</select>';
    $form_inputs['fields'][$field_id] = array( 'type' => $matches[1][$i], 'label' => $label, 'required' => $required );
    }
    }

    if( $matches[1][$i] == 'autoresponder' ) {
    $name = ( !empty( $matches[2][$i]['fromname'] ) ) ? $matches[2][$i]['fromname'] : get_bloginfo('name');
    $email = ( !empty( $matches[2][$i]['fromemail'] ) ) ? trim( $matches[2][$i]['fromemail'] ) : $form_inputs['mysite_email'];
    $subject = ( !empty( $matches[2][$i]['subject'] ) ) ? $matches[2][$i]['subject'] : false;
    $message = ( !empty( $matches[2][$i]['message'] ) ) ? $matches[2][$i]['message'] : false;
    $form_inputs['autoresponder'][] = array( 'name' => $name, 'email' => $email, 'subject' => $subject, 'message' => $message );
    }

    $out .= '</div>';
    }
    }

    if( $captcha == 'true' ) {

    $field_id = "mysite_field{$i}{$form_id}";

    if( isset( $errored_fields ) )
    $required_error = ( !in_array( $field_id, $errored_fields ) ) ? '' : ' required_error';

    $out .= '<div class="mysite_form_row captcha_row">';

    $num1 = rand(1,10);
    $num2 = rand(1,10);
    $label = $num1 .' + '. $num2 . ' ';

    $out .= '<label for="' . $field_id . '">' . $label . '</label>';

    $out .= '<input type="text" name="' . $field_id . '" id="' . $field_id . '" class="textfield required' . $required_error . '" value="' .
    ( isset( $_POST[$field_id] ) ? esc_attr( $_POST[$field_id] ) : '' ) . '" />';
    $form_inputs['fields'][$field_id] = array( 'type' => 'captcha', 'label' => $label, 'required' => 'captcha' );

    $form_inputs['fields'][$field_id]['captcha'] = $num1+$num2;

    $out .= '</div>';
    }

    if( $out_submit ) {
    $out .= $out_submit;
    }

    if( !$submit_button ) {
    $out .= '<div class="mysite_form_row">';
    $out .= '<input type="submit" value="' . __( 'Submit', MYSITE_TEXTDOMAIN ) . '" class="contact_form_submit fancy_button" />';

    $out .= '<div class="mysite_contact_feedback">';
    $out .= '<img src="' . esc_url( THEME_IMAGES_ASSETS . '/transparent.gif' ) . '" style="background-image: url(' . THEME_IMAGES_ASSETS . '/preloader.png);">';
    $out .= '</div>';

    $out .= '</div>';
    }[/code]

    Posted 4 years ago #
  11. Will this be resolved in any updates? It is still an issue.

    Posted 2 years ago #

Reply

You must log in to post.

Construct WordPress Theme
Construct wordpress theme
Myriad WordPress Theme
Myriad wordpress theme
Method WordPress Theme
Method wordpress theme
Fusion WordPress Theme
Fusion wordpress theme
Elegance WordPress Theme
Elegance wordpress theme
Echelon WordPress Theme
Echelon wordpress theme
Dejavu WordPress Theme
Dejavu wordpress theme
Modular WordPress Theme
Modular wordpress theme