{"id":36494,"date":"2015-05-22T00:39:21","date_gmt":"2015-05-22T00:39:21","guid":{"rendered":"https:\/\/wordpress.org\/plugins-wp\/contact-form-7-dynamic-mail-to\/"},"modified":"2018-07-27T13:46:52","modified_gmt":"2018-07-27T13:46:52","slug":"contact-form-7-dynamic-mail-to","status":"closed","type":"plugin","link":"https:\/\/mlt.wordpress.org\/plugins\/contact-form-7-dynamic-mail-to\/","author":10176418,"comment_status":"closed","ping_status":"closed","template":"","meta":{"version":"1.0.0","stable_tag":"1.0.0","tested":"4.9.30","requires":"4.0","requires_php":"","requires_plugins":"","header_name":"Dynamic Recipient for Contact Form 7","header_author":"John A. Huebner II","header_description":"","assets_banners_color":"","last_updated":"2018-07-27 13:46:52","external_support_url":"","external_repository_url":"","donate_link":"https:\/\/www.paypal.com\/cgi-bin\/webscr?cmd=_donations&business=hube02%40earthlink%2enet&lc=US&item_name=Donation%20for%20WP%20Plugins%20I%20Use&no_note=0&cn=Add%20special%20instructions%20to%20the%20seller%3a&no_shipping=1&currency_code=USD&bn=PP%2dDonationsBF%3abtn_donateCC_LG%2egif%3aNonHosted","header_plugin_uri":"https:\/\/github.com\/Hube2\/contact-form-7-dynamic-mail-to","header_author_uri":"https:\/\/github.com\/Hube2\/","rating":3,"author_block_rating":0,"active_installs":200,"downloads":6340,"num_ratings":0,"support_threads":1,"support_threads_resolved":1,"author_block_count":0,"sections":["description","installation","faq","changelog"],"tags":[],"upgrade_notice":[],"ratings":{"1":"1","2":0,"3":0,"4":0,"5":"1"},"assets_icons":[],"assets_banners":[],"assets_blueprints":{},"all_blocks":[],"tagged_versions":["1.0.0"],"block_files":[],"assets_screenshots":{"screenshot-1.png":{"filename":"screenshot-1.png","revision":"1915911","resolution":"1","location":"plugin"}},"screenshots":{"1":"Special Fields in CF7 Example"}},"plugin_section":[74],"plugin_tags":[2845,1152,1506,19479,19480],"plugin_category":[],"plugin_contributors":[83588],"plugin_business_model":[],"class_list":["post-36494","plugin","type-plugin","status-closed","hentry","plugin_section-adopt-me","plugin_tags-adopt-me","plugin_tags-contact-form-7","plugin_tags-dynamic","plugin_tags-mail-to","plugin_tags-recipient","plugin_contributors-hube2","plugin_committers-hube2"],"banners":[],"icons":{"svg":false,"icon":"https:\/\/s.w.org\/plugins\/geopattern-icon\/contact-form-7-dynamic-mail-to.svg","icon_2x":false,"generated":true},"screenshots":[{"src":"https:\/\/ps.w.org\/contact-form-7-dynamic-mail-to\/trunk\/screenshot-1.png?rev=1915911","caption":"Special Fields in CF7 Example"}],"raw_content":"<!--section=description-->\n<p>Addopt this plugin. <a href=\"https:\/\/github.com\/Hube2\/contact-form-7-dynamic-mail-to\">Please see details on Github<\/a>.<\/p>\n\n<p>Dynamically set recipitent of mail using a filter.<\/p>\n\nHow To Use\n\n<p>Create a filter that will return the recipient of mail. For more information see the example filter in\ncf7-dynamic-mail-to-examples.php included with the plugin.<\/p>\n\n<pre><code>function wpcf7_dynamic_to_filter_example($recipient, $args=array()) {\n  if (isset($args['select-email'])) {\n    if ($args['select-email'] == 'send to email 1') {\n      $recipient = 'email-01@email.com';\n    } elseif ($args['select-email'] == 'send to email 2') {\n      $recipient = 'email-01@email.com';\n    } elseif ($args['select-email'] == 'sent to email 3') {\n      $recipient = 'email-01@email.com';\n    }\n  }\n  return $recipient;\n} \/\/ end function wpcf7_dynamic_to_filter_example\nadd_filter('wpcf7-dynamic-recipient-example-filter', 'wpcf7_dynamic_to_filter_example', 10, 2);\n<\/code><\/pre>\n\n<p>Add special fields to your form, see screenshot of example fields.<\/p>\n\n<p>Add a field to you form with the name \"dynamic-mail-to-filter\". This can be any type of field that holds\na single value. I would suggest trying out my other plugin\n<a href=\"https:\/\/wordpress.org\/plugins\/contact-form-7-simple-hidden-field\/\">Contact Form 7 - Simple Hidden Field<\/a>. \nYou can also use another hidden field extension for CF7. Set the value of this field to the name of your\nfilter hook.<\/p>\n\n<p>If you would like the values of other fields sent to your filter as arguments, add a field with the name of\n\"dynamic-mail-to-fields.\" Set the value of this field to a comma separated list of the fields values you \nwant sent to your filter. Again, see the example filter supplied with this plugin.<\/p>\n\n<!--section=installation-->\n<ol>\n<li>Upload the files to the plugin folder of your site<\/li>\n<li>Activate it from the Plugins Page<\/li>\n<\/ol>\n\n<!--section=faq-->\n<dl>\n<dt>Installation Instructions<\/dt>\n<dd><ol>\n<li>Upload the files to the plugin folder of your site<\/li>\n<li>Activate it from the Plugins Page<\/li>\n<\/ol><\/dd>\n<dt>Tell me how to use this thing again<\/dt>\n<dd><p>It seems that my instructions in the description are not exactly clear, so here's a step by step<\/p>\n\n<ol>\n<li>Add a hidden field to your form. This hidden field can be added using my other plugin <a href=\"https:\/\/wordpress.org\/plugins\/contact-form-7-simple-hidden-field\/\">Hidden Field for Contact Form 7<\/a>. I believe that there are other plugins available that will let you do this.\nThe name of this hidden field must be <code>dynamic-mail-to-filter<\/code> and the value of this hidden field should be the filter hook that this plugin should use to get your dynamic value. For example, if this is the code used to set up the filter and function:\n`<\/li>\n<\/ol>\n\n<p>add_filter('my_dynamic_mailto_hook', 'my_dynamic_mailto_function', 10, 2);<\/p>\n\n<pre><code>`\n<\/code><\/pre>\n\n<p>then the value of this hidden field should be <code>my_dynamic_mailto_hook<\/code>.<\/p>\n\n<ol>\n<li>Set up optional parameters. This allows you to pass the values of other fields in your form to your filter function so that they can be used in determining the mailto address to return.  <\/li>\n<\/ol>\n\n<p>For example, you could pass the post ID value of the current page. First set up a hidden field that contains the post ID. This can also be done with my hidden field plugin and with other plugins. Let's say for example that you name this field <code>post-id<\/code>. To pass the value of this field to your filter you would then create another hidden field. The name of this hidden field must be <code>dynamic-mail-to-fields<\/code>. The value of this field would be <code>post-id<\/code>. The value of this field should be a comma seperated list of all the other field names that you want to pass to your filter. For example if we wanted to use 2 fields named <code>post-id<\/code> and <code>user-id<\/code> then the value of the hidden field named <code>dynamic-mail-to-fields<\/code> would be <code>post-id,user-id<\/code>. Now let's assume that this is the code of your function\n    `<\/p>\n\n<p>function my_dynamic_mailto_function($recipient, $args) {\n  \/\/ the code of your function here\n}<\/p>\n\n<pre><code>`\n<\/code><\/pre>\n\n<p>and we have set up the <code>dynamic-mail-to-fields<\/code> field to have the value of <code>post-id,user-id<\/code>, in this case the value of <code>$args<\/code> would be\n    `<\/p>\n\n<p>Array (\n  'post-id' =&gt; '10', \/\/ assuming the post id was 10\n  'user-id' =&gt; '5',  \/\/ assuming the user id was 5\n)<\/p>\n\n<pre><code>`\n<\/code><\/pre>\n\n<ol>\n<li>Complete your function that determines who the recipient (or recipients) of your form should be. You can return a single email address or a comma separated list of email addresses. For example\n\n<ul>\n<li>someone@somewhere.com<\/li>\n<li>John Doe <a href=\"mailto:&#106;&#111;&#x68;&#x6e;&#100;&#x6f;&#x65;&#064;g&#x6f;&#111;&#103;&#x6c;&#101;&#046;&#x63;&#x6f;&#109;\">&#106;&#111;&#x68;&#x6e;&#100;&#x6f;&#x65;&#064;g&#x6f;&#111;&#103;&#x6c;&#101;&#046;&#x63;&#x6f;&#109;<\/a><\/li>\n<li>someone@somewhere.com, John Doe <a href=\"mailto:&#106;&#111;&#x68;&#x6e;&#100;&#x6f;&#x65;&#064;g&#x6f;&#111;&#103;&#x6c;&#101;&#046;&#x63;&#x6f;&#109;\">&#106;&#111;&#x68;&#x6e;&#100;&#x6f;&#x65;&#064;g&#x6f;&#111;&#103;&#x6c;&#101;&#046;&#x63;&#x6f;&#109;<\/a><\/li>\n<\/ul><\/li>\n<\/ol><\/dd>\n<dt>Why Filters?<\/dt>\n<dd><p>Many other plugins of this type use shortcodes. I'm not a real fan of shortcodes, but that's not the only\nreason.<\/p>\n\n<p>Filters are much more flexible that shortcodes.<\/p>\n\n<p>For example, a shortcode cannot return an array. A shortcode pretty much requires that only a text value is returned.<\/p><\/dd>\n\n<\/dl>\n\n<!--section=changelog-->\n<h4>1.0.0<\/h4>\n\n<ul>\n<li>initial release<\/li>\n<\/ul>","raw_excerpt":"Set recipient email dynamically by useing a filter","jetpack_sharing_enabled":true,"_links":{"self":[{"href":"https:\/\/mlt.wordpress.org\/plugins\/wp-json\/wp\/v2\/plugin\/36494","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/mlt.wordpress.org\/plugins\/wp-json\/wp\/v2\/plugin"}],"about":[{"href":"https:\/\/mlt.wordpress.org\/plugins\/wp-json\/wp\/v2\/types\/plugin"}],"replies":[{"embeddable":true,"href":"https:\/\/mlt.wordpress.org\/plugins\/wp-json\/wp\/v2\/comments?post=36494"}],"author":[{"embeddable":true,"href":"https:\/\/mlt.wordpress.org\/plugins\/wp-json\/wporg\/v1\/users\/hube2"}],"wp:attachment":[{"href":"https:\/\/mlt.wordpress.org\/plugins\/wp-json\/wp\/v2\/media?parent=36494"}],"wp:term":[{"taxonomy":"plugin_section","embeddable":true,"href":"https:\/\/mlt.wordpress.org\/plugins\/wp-json\/wp\/v2\/plugin_section?post=36494"},{"taxonomy":"plugin_tags","embeddable":true,"href":"https:\/\/mlt.wordpress.org\/plugins\/wp-json\/wp\/v2\/plugin_tags?post=36494"},{"taxonomy":"plugin_category","embeddable":true,"href":"https:\/\/mlt.wordpress.org\/plugins\/wp-json\/wp\/v2\/plugin_category?post=36494"},{"taxonomy":"plugin_contributors","embeddable":true,"href":"https:\/\/mlt.wordpress.org\/plugins\/wp-json\/wp\/v2\/plugin_contributors?post=36494"},{"taxonomy":"plugin_business_model","embeddable":true,"href":"https:\/\/mlt.wordpress.org\/plugins\/wp-json\/wp\/v2\/plugin_business_model?post=36494"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}