• Resolved aviv86

    (@aviv86)


    Hi. I’m treating a checkbox a little differently and have a question about formatting the output from that box in the email message.
    Instead of this:
    [checkbox events id:events class:contactForm "CEREMONY" "DRINKS & LAWN GAMES" "RECEPTION"]

    I’m using this, so that I can have a running total of the number of events that are checked:

    <label for="events">the festivities for&nbsp;<a id="status"><font id="count" color="#ffbdb3">[count id:count 0]</font><font color="#ffbdb3">&nbsp;events.</font></a></label>
          	<input type="checkbox" name="event-ceremony" />&nbsp;CEREMONY
            <input type="checkbox" name="event-drinks" />&nbsp;DRINKS & LAWN GAMES
            <input type="checkbox" name="event-reception" />&nbsp;RECEPTION

    So, question 1) Is there a way to use the simple CF7 shortcode and still have a running total of events?
    or, question 2) Can I use my existing code and change what appears in the email to “Yes” / “No”? Right now, this is what I have for the email shortcode:

    <strong>Ceremony</strong> [event-ceremony]
    <strong>Drinks & Lawn Games</strong> [event-drinks]
    <strong>Reception</strong> [event-reception]

    And this is what see when I receive an email (I’ve checked the first two, and left the third blank):
    Ceremony on
    Drinks & Lawn Games on
    Reception [event-reception]

    https://www.ads-software.com/plugins/contact-form-7/

Viewing 5 replies - 1 through 5 (of 5 total)
  • Thread Starter aviv86

    (@aviv86)

    Figured something out.

    @aviv86 – that’s a very interesting use of CF7. Are you able to share your completed solution.

    Thread Starter aviv86

    (@aviv86)

    @buzztone Hmm for the countdown script, I think I searched and found something like this, and added it to one of the plug-in .js files: https://stackoverflow.com/questions/24478360/jquery-count-number-of-checked-checkboxes-with-a-given-id-value

    I had already added this (below) to the theme functions.php file, to hide blank fields (that way, when I receive an email, it just tells me which events they’re coming to, omitting the unchecked boxes):

    // Don't show blank fields in email for WPCF7
    add_filter( 'wpcf7_mail_components', 'remove_blank_lines' );
    
    function remove_blank_lines( $mail ) {
    	if ( is_array( $mail ) && ! empty( $mail['body'] ) )
    		$mail['body'] = preg_replace( '|\n\s*\n|', "\n\n", $mail['body'] );
    
    	return $mail;
    }

    And now for the easy part. This is the countdown and checkbox form code I used:

    <label for="events"><a id="status"><font id="count" color="#ffbdb3">[count id:count 0]</font><font color="#ffbdb3">?events.</font></a></label>
    		[checkbox events id:events class:contactForm "CEREMONY" "DRINKS & LAWN GAMES" "RECEPTION"]

    And this is the shortcode for the email form: [events]

    Hope that helps. Live example is temporarily here, if you’re interested.

    @aviv86 – Thanks for that – I found your combining of standard HTML elements with CF7 shortcodes really interesting.

    Thread Starter aviv86

    (@aviv86)

    @buzztone In all honesty, I’m certain there are better ways to apply the styling and attributes that I’ve managed to hack together. I just did a little trial and error and pieced together a form that works for my RSVP page. Thanks for the interest.

Viewing 5 replies - 1 through 5 (of 5 total)
  • The topic ‘Change [checkbox] output in email from "on"?’ is closed to new replies.