Forum Replies Created

Viewing 15 replies - 31 through 45 (of 58 total)
  • Aha! Yes, I’ve had that issue before.

    Be sure to mark this as resolved!

    In your stylesheet, you need to use a proper selector and force the select to display inline.

    Example CSS:

    .wpcf7-form select { display: inline; }

    the problem will be that your validation messages may not display properly.

    Is it necessary to use CF7 for this?

    PayPal can generate forms for you. I suppose we’d need to know more info.

    CF7 uses jQueryUI’s datepicker.. this means you can use the “setDefaults()” method to set localization.

    See: https://api.jqueryui.com/datepicker/#utility-functions

    You can look in the “Form” text box and edit field tags.

    The right-hand side helps generate form tags… they are along the lines of:

    [text* name 123/456 id:optional_id class:optional_class placeholder "optional default value"]

    Each element above, explained:

    text: this is the type of input field.. text, textarea, radio, checkbox, number, email, etc. fields below are for TEXT as each field varies
    * (asterisk, optional): asterisk denotes required field
    123: size
    456: max length
    id:optional_id — the html ID attribute of the field
    class:optional_class — the html CLASS attribute of the field
    placeholder: denotes to use default value as placeholder text (instead of using a label)
    “optional default value”: the default value or placeholder text.

    Actually, his error is because there is code in his functions.php file (probably an action on wpcf7_before_send_mail) which is using old code.

    Your functions.php file wpcf7_before_send_mail action needs to be modified to work with CF7 3.9 or greater. Otherwise, you need to downgrade to CF7 3.8.x.

    You should upload the PDF somewhere (either on your server, or on your CDN) and simply link to the PDF in your mail(2) message body.

    This can be accomplished via JS:

    $('#form_id_here').bind("keyup keypress", function(e) {
      var code = e.keyCode || e.which;
      if (code == 13) {
        e.preventDefault();
        return false;
      }
    });

    Replace the #form_id_here with the appropriate form ID, or simply use “form” to disable submit on ALL forms via the enter key.

    A pure JS solution could be done…

    First, create a hidden field in the form named “seat” or whatever.

    Then, place an image in your page. Use some JS to detect where the user clicked within the image (hint: you can create bounding boxes in x1,y1,x2,y2 in an array). Then, create a click handler that updates the “seat” hidden form field.

    Yes. In your CF7 additional settings, enter:

    on_sent_ok: "handleCF7Submit(this);"

    (Note: If I recall correctly, this will be the form object… but I can’t remember)

    Then, in your JS file, define the function:

    function handleCF7Submit(form) {
      $("submit button selector", $(form)).val('SUCCESS!');
    }

    Of course, you’ll need to modify that JS code to make it work, but this should get you going.

    I cannot post without all 4 forms filled out.

    This is possible using the pipes code… see: https://contactform7.com/selectable-recipient-with-pipes/

    If this doesn’t work, you may need to create a new action:
    add_action('wpcf7_before_send_mail', 'custom_wpcf7_before_send_mail');

    and handle recipients here based on conditions from form post. Example:

    add_action('wpcf7_before_send_mail', 'custom_wpcf7_before_send_mail');
    function custom_wpcf7_before_send_mail($form) {
        $wpcf7 = WPCF7_ContactForm::get_current();
        $submission = WPCF7_Submission::get_instance();
        $data = $submission->get_posted_data();
    
        if(empty($data)) return;
    
        // assuming this is a post of an array of CHECKBOXES -- named "recipients" with email addresses of values. NOTE: See NOTE, below code.
        $recipients = isset($data['recipients']) ? $data['recipients'] : false;
    
        $recipientsList = array();
        if($recipients) {
          foreach($recipients as $recipient) {
            $recipientsList[] = $recipient;
          }
        }
    
        $mail = $wpcf7->prop('mail');
        $mail['recipient'] = implode(",", $recipientsList);
        $wpcf7->set_properties(array("mail" => $mail));
    
        return $wpcf7;
    }

    NOTE: I highly suggest against using email addresses in values of HTML elements due to web scrapers/spammers. Instead, use something else like ID #’s or names, then reference them back in your code and then setup the recipients.

    Need more info. Any error messages? Are you sure it’s CF7? I haven’t had a problem with it in WP4

    Try creating a test.php file and use PHP’s mail() function to test your sendmail functionality.. if it doesn’t work, there may be an issue with your server configuration.

    Since CF7 v3.9, you have to do this differently.

    See below for example:

    add_action('wpcf7_before_send_mail', 'custom_wpcf7_before_send_mail');
    function custom_wpcf7_before_send_mail($form) {
      $id = $form->id; // gets current form id
    
      // CF7 form id => "form label (for you to distinguish)" -- you don't need this, but if you use multiple forms, it may be useful to TARGET x, y, or z forms instead of all forms
      $formTypes = array(
        176 => "Contact Page",
        //202 => "Questions/Comments Form"
      );
    
      // check if we want to run this code on selected form
      if(array_key_exists($id, $formTypes)) {
        // get current FORM instance
        $wpcf7 = WPCF7_ContactForm::get_current();
    
        // get current SUBMISSION instance
        $submission = WPCF7_Submission::get_instance();
    
        // get submission data
        $data = $submission->get_posted_data();
    
        // nothing's here... do nothing...
        if(empty($data)) return;
    
        // extract posted data
        $name     = isset($data['your-name'])     ? $data['your-name']     : "";
        $email    = isset($data['email'])         ? $data['email']         : "";
        $phone    = isset($data['phone'])         ? $data['phone']         : "";
        $message  = isset($data['message'])       ? $data['message']       : "";
    
        // do other stuff here
    
        // maybe do some replacements in the cf7 email body?
        $mail = $wpcf7->prop('mail');
    
        // Find/replace the "special" tag as defined in your CF7 email body
        $mail['body'] = str_replace("[MyCustomTag]", "Some dynamic text here", $mail['body']);
    
        // Save the email body
        $wpcf7->set_properties(array("mail" => $mail));
    
        // return current cf7 instance
        return $wpcf7;
      }
    }
Viewing 15 replies - 31 through 45 (of 58 total)