Forum Replies Created

Viewing 15 replies - 16 through 30 (of 34 total)
  • Thread Starter vader7071

    (@vader7071)

    John, have you had a chance to look at my updated information?

    Thread Starter vader7071

    (@vader7071)

    An update. In my CF7 Form tab, I have these 2 lines:

    [simplehidden wpcf7-dynamic-mail-to-filter "subject"]
    [simplehidden wpcf7-dynamic-mail-to-filter "mail-to"]

    In my CF7 Mail tab, I have these 2 lines:

    [mail-to]
    [wpcf7-dynamic-mail-to-filter]

    In the plugin folder (contact-form-7-dynamic-mail-to) I have a file named

    cf7-dynamic-mail-to.php

    that has the following code. This same code is also in my

    function.php

    file for the theme.

    new wpcf7_dynamic_email_to();
    	
    	class wpcf7_dynamic_email_to {
    		
    		// these are the email addresses to be used to for setting the recipient email address in cf7
    		private $email_address_1 = '[email protected]';
    		private $email_address_2 = '[email protected]';
    		private $email_address_3 = '[email protected]';
    		private $email_address_4 = '[email protected]';
    		private $email_address_5 = '[email protected]';
    		
    		public function __construct() {
    			add_filter('wpcf7-dynamic-email-to', array($this, 'filter'), 10, 2);
    		} // end public function __construct
    		
    		public function filter($recipient, $args=array()) {
    			//echo '(',$recipient,')';
    			//print_r($args); die;
    			if (isset($args['subject'])) {
    				if ($args['subject'] == 'Becoming an athletic competitor') {
    					$recipient = $this->email_address_1;
    				} elseif ($args['subject'] == 'Sponsoring the Highland Games') {
    					$recipient = $this->email_address_2;
    				} elseif ($args['subject'] == 'Wanting to be a Vendor') {
    					$recipient = $this->email_address_3;
    				} elseif ($args['subject'] == 'Clan Information') {
    					$recipient = $this->email_address_4;
    				} elseif ($args['subject'] == 'Something not listed here') {
    					$recipient = $this->email_address_5;
    				}
    			}
    			return $recipient;
    		} // end public function filter
    		
    	} // end class wpcf7_dynamic_mail_to

    Here are my results.

    When I send the email, this is what I get:

    [mail-to]
    mail-to

    So the [mail-to] tag is not getting filled and the form is just dumping the place holder as is. But the tag [wpcf7-dynamic-mail-to-filter] is getting filled with “mail-to”.

    So, here is where I am. I have made a little progress, but I am still at a loss. I cannot seem to find why the tags are not being filled properly.

    • This reply was modified 6 years, 10 months ago by vader7071.
    Thread Starter vader7071

    (@vader7071)

    Trying to get this figured out, let me share what all I have right now.

    1) I have the “Dynamic Recipient for Contact Form 7” plugin added. I also have the “Hidden Field” as well.

    In /[root]/wp-content/plugins/contact-form-7-dynamic-mail-to I have these files:
    cf7-dynamic-mail-to.php
    cf7-dynamic-mail-to-examples.php
    README.md
    readme.txt

    I have gone into examples and copied the code into notepad and modified it to what I need. I then used the example code and replace the code in just “cf7-dynamic-mail-to.php”. This is what I have:

    <?php 
    	/*
    		Plugin Name: Dynamic Recipient for Contact Form 7
    		Plugin URI: https://github.com/Hube2/contact-form-7-dynamic-mail-to
    		Description: Alter the to email address of mail in Contact Form 7 dynamically. Requires Contact Form 7
    		Version: 1.0.0
    		Author: John A. Huebner II
    		Author URI: https://github.com/Hube2/
    		License: GPL
    	*/
    
    	// If this file is called directly, abort.
    	if (!defined('WPINC')) { die; }
    	
    	//include(dirname(__FILE__).'/cf7-dynamic-mail-to-examples.php');
    	
    	new wpcf7_dynamic_mail_to();
    	
    	class wpcf7_dynamic_mail_to {
    		
    		// these are the email addresses to be used to for setting the recipient email address in cf7
    		private $email_address_1 = '[email protected]';
    		private $email_address_2 = '[email protected]';
    		private $email_address_3 = '[email protected]';
    		private $email_address_4 = '[email protected]';
    		private $email_address_5 = '[email protected]';
    		
    		public function __construct() {
    			add_filter('wpcf7-dynamic-mail-to-filter', array($this, 'filter'), 10, 2);
    		} // end public function __construct
    		
    		public function filter($recipient, $args=array()) {
    			//echo '(',$recipient,')';
    			//print_r($args); die;
    			if (isset($args['subject'])) {
    				if ($args['subject'] == 'Becoming an athletic competitor') {
    					$recipient = $this->email_address_1;
    				} elseif ($args['subject'] == 'Sponsoring the Highland Games') {
    					$recipient = $this->email_address_2;
    				} elseif ($args['subject'] == 'Wanting to be a Vendor') {
    					$recipient = $this->email_address_3;
    				} elseif ($args['subject'] == 'Clan Information') {
    					$recipient = $this->email_address_4;
    				} elseif ($args['subject'] == 'Something not listed here') {
    					$recipient = $this->email_address_5;
    				}
    			}
    			return $recipient;
    		} // end public function filter
    		
    	} // end class wpcf7_dynamic_mail_to
    	
    ?>

    In my Contact Form 7 form, I have this code:

    <label> 
        [text* your-name placeholder 'Your Name *' ] </label>
    
    <label>
        [email* your-email placeholder 'Your Email *'] </label>
    
    <label> 
        [select* subject "Becoming an athletic competitor" "Sponsoring the Highland Games" "Wanting to be a Vendor" "Clan Information" "Something not listed here"]</label>
    
    <label>
        [textarea* your-message placeholder 'Your Message *'] </label>
    
    [simplehidden wpcf7-dynamic-mail-to-filter "mail-to"]
    [simplehidden wpcf7-dynamic-mail-to-filter "subject"]
    
    [submit "Send"]

    Then in my “Mail” settings, in the body of the email, I have a tag [mail-to] just to make sure it is changing.

    Everything looks like it should work, but it isn’t. The PHP file that the code is in is called “cf7-dynamic-mail-to.php” while the filter being called is “wpcf7-dynamic-mail-to”. Could that be the issue? I am at a total loss of what I have wrong or what I have missing.

    • This reply was modified 6 years, 10 months ago by vader7071.
    Thread Starter vader7071

    (@vader7071)

    That did it!!! Perfect! Thank you.

    Thread Starter vader7071

    (@vader7071)

    Right now I have Dynamic Recipient for Contact Form 7 and Hidden Field for Contact Form 7 loaded. I am loading Dynamic Select now.

    Am I headed in the right direction?

    Am I correct putting the code in my function.php file?

    • This reply was modified 6 years, 10 months ago by vader7071.
    Thread Starter vader7071

    (@vader7071)

    Hi John. Yeah, I pretty much had myself totally confused in the beginning. Let’s see if I can start over and make it simple.

    I found your plugin (Dynamic Recipient for Contact Form 7). I believe this will do what I want to do. I found it after I started this thread. So if I need to move this, I don’t mind.

    That being said. I have a drop down list for my tag called [subject]. The user can choose one of 5 choices.

    What I am trying to accomplish, is to change the value of a tag [mail-to] (this can be called anything) based on what is in [subject].

    Looking at Dynamic Recipient for Contact Form 7, it looks like that filter does just that. However, I am not getting the output. When the email sends, the tag [mail-to] remains exactly that, “[mail-to]”. It does not update.

    For testing purposes, I have the email going to a static email address and just a tag in the body that changes so I can see what is going on.

    In my second post, the upper block of code is what I have put into my function.php file. I constructed that from looking at the plugin examples.

    Thread Starter vader7071

    (@vader7071)

    Ok, tried to go back and edit. Just about everything I have above is incorrect.

    Here is what I have now, after a little more digging and understanding.

    In my “Contact Form 7” code:

    <label> 
        [text* your-name placeholder 'Your Name *' ] </label>
    
    <label>
        [email* your-email placeholder 'Your Email *'] </label>
    
    <label> 
        [select* subject "Becoming an athletic competitor" "Sponsoring the Highland Games" "Wanting to be a Vendor" "Clan Information" "Something not listed here"]</label>
    
    <label>
        [textarea* your-message placeholder 'Your Message *'] </label>
    
    [simplehidden dynamic-mail-to-filter "mail-to"]
    [simplehidden dynamic-mail-to-fields "subject"]
    
    [submit "Send"]

    FYI, [mail-to] is the tag I am trying to have change.

    I have added this snipped of code into my function.php file for the theme:

    /**
     * Dynamic Mail-To fields for Contact Form
     */
    /*  Select Mail  */
    
    function __construct() {
    	add_filter('wpcf7-dynamic-mail-to-example-filter', array($this, 'filter'), 10, 2);
    } // end public function __construct
    
    function filter($recipient, $args=array()) {
    	if (isset($args['subject'])) {
    		if ($args['subject'] == 'Becoming an athletic competitor') {
          		$recipient = '[email protected]';
        	} elseif ($args['subject'] == 'Sponsoring the Highland Games') {
          		$recipient = '[email protected]';
        	} elseif ($args['subject'] == 'Wanting to be a Vendor') {
          		$recipient = '[email protected]';
        	} elseif ($args['subject'] == 'Clan Information') {
          		$recipient = '[email protected]';
        	} elseif ($args['subject'] == 'Something not listed here') {
          		$recipient = '[email protected]';
        	}
    	}
    	return $recipient;
    }

    When I run the form from my website, this is the body that is transmitted:

    From: [your-name] <[your-email]>
    Subject: [subject]
    
    [mail-to]
    
    Message Body:
    [your-message]
    
    -- 
    This e-mail was sent from a contact form on domain.com

    The [mail-to] is just to see if it is changing. When I test, the [mail-to] does not change. It remains exactly [mail-to]. It doesn’t even populate from the filter.

    Thread Starter vader7071

    (@vader7071)

    Update, Your plugin actually plays a role to accomplish this.

    Doing some reading, what I have to do is use Contact Form 7 to create the form layout.

    Then I use Conditional Fields for Contact Form 7 to set groups based on which subject is selected.

    Once I have the group activated based on the subject, then inside the group, I set my [mail-to] tag to change the email address I am sending to.

    But here is where I am struggling some. I think I need to use the Hidden Field for Contact Form 7 plugin as well. But I am still working on the group staging to make sure I am correct.

    One step at the time.

    Thread Starter vader7071

    (@vader7071)

    That is close, thank you. But how do I modify a second mail-tag?

    In logic code, I need:

    If [subject] = Selection_A
    [mailto] = email_1; email_2

    else If [subject] = Selection_B
    [mailto] = email_3; email_4

    else If [subject] = Selection_C
    [mailto] = email_5

    else If [subject] = Selection_D
    [mailto] = email_5; email_6; email_7

    But that was helpful to know I can hide information in the background. Thank you.

    Thread Starter vader7071

    (@vader7071)

    Oh, I apologize. I wasn’t sure if this would be handled via your add-on or the original plugin. But thank you for helping!

    I will try your suggestion. THANKS!

    Thread Starter vader7071

    (@vader7071)

    Oh, even better. I’ll make that change. Thank you!

    Thread Starter vader7071

    (@vader7071)

    That was perfect. My main page (with all entries) paginates to 10 (I used datatables_paginate_entries=10 ) and all of my decades paginate to 11 (I used datatables_paginate_entries=11 ). Exactly what I want. Thank you.

    Thread Starter vader7071

    (@vader7071)

    Oh perfect. Thanks. So under table settings, ignore the paginate portion there, and just use this shortcode in its place.

    Thread Starter vader7071

    (@vader7071)

    That is EXACTLY what I was looking for! Well worth the $20! Thank you.

    @aga2442, the plugin updates fixed the issue for me on all my sites.

Viewing 15 replies - 16 through 30 (of 34 total)