Digital experiences for all disciplines
New Landing › How can we help? › Themeforest Theme Support › Neighborhood › MODIFY Contact 7 for mymail_snippet
New Landing › How can we help? › Themeforest Theme Support › Neighborhood › MODIFY Contact 7 for mymail_snippet
- This topic has 10 replies, 2 voices, and was last updated 10 years by Mohammad – SUPPORT.
-
Posted in: Neighborhood
-
September 28, 2014 at 3:03 pm #115172
I am in dire need of help. Where do I put his into the theme http://pastebin.com/K26xZEy3
I created four check-buttons in contact 7. The idea is that when one person use the contact form, there is a check mark list,wedding, engagement, portrait, and others, it will send an email autoresponder according to the option selected. When they use the contact form, they automatically are registered for my mail.Here’s the quick snippet that was provided.
* requires a checkbox with the the name “newsletter” in your CF7
*/
function wpcf7_my_validate( $result, $tag ) {
$type = $tag[‘type’];
$name = $tag[‘name’];if ( ‘newsletter’ == $name ) {
$subscribe = isset($_POST[$name]);if(function_exists(‘mymail’) && $subscribe){
$userdata = array(
’email’ => $_POST[’email’],
‘firstname’ => $_POST[‘firstname’],
‘lastname’ => $_POST[‘lastname’],
);
$list_ids = array(123, 456); // your list ids
$overwrite = true;
$subscriber_id = mymail(‘subscribers’)->add($userdata, $overwrite);
if(!is_wp_error($subscriber_id)){
mymail(‘subscribers’)->assign_lists($subscriber_id, $list_ids);
}
}
}return $result;
}
add_filter( ‘wpcf7_validate_checkbox’, ‘wpcf7_my_validate’, 10, 2 );September 28, 2014 at 3:04 pm #115173This reply has been marked as private.September 29, 2014 at 9:26 am #115349Hi,
Please insert this code at functions.php of child theme. Its write place to put any custom php code. Make sure that you have activated child theme.
Thanks
With Best Regards
MohammadSeptember 29, 2014 at 1:17 pm #115492would this be the right approach.http://www.youtube.com/watch?v=Za5YAUMqWvo or here the direction i followed http://www.gregreindel.com/wordpress-custom-functions-file/
this is the procedure i done.
1. Create a folder within your child theme named “lib”
2. Within the new “lib” folder, create a file named “my_functions.php”<?php
/**
* My Custom Functions
*/Save.
3. Paste this code in your themes current functions.php file
// Add My Custom Functions File
include_once( get_stylesheet_directory() . ‘/lib/my_functions.php’ );Save.
4. I added the this int my_functions.php* requires a checkbox with the the name “newsletter” in your CF7
*/
function wpcf7_my_validate( $result, $tag ) {
$type = $tag[‘type’];
$name = $tag[‘name’];if ( ‘newsletter’ == $name ) {
$subscribe = isset($_POST[$name]);if(function_exists(‘mymail’) && $subscribe){
$userdata = array(
‘email’ => $_POST[’email’],
‘firstname’ => $_POST[‘firstname’],
‘lastname’ => $_POST[‘lastname’],
);
$list_ids = array(123, 456); // your list ids
$overwrite = true;
$subscriber_id = mymail(‘subscribers’)->add($userdata, $overwrite);
if(!is_wp_error($subscriber_id)){
mymail(‘subscribers’)->assign_lists($subscriber_id, $list_ids);
}
}
}return $result;
}
add_filter( ‘wpcf7_validate_checkbox’, ‘wpcf7_my_validate’, 10, 2 );would this be correct? i put this under neighborhood. i don’t know whats a child theme.
September 29, 2014 at 5:16 pm #115620SCRATCH EVERYTHING! I finally know how to make a child theme. I am now procedding to “Please insert this code at functions.php of child theme” What should the functions.php hold?
This is what i input
<?php // Opening PHP tag – nothing should be before this, not even whitespace
/*
* requires a checkbox with the the name “newsletter” in your CF7
*/
function wpcf7_my_validate( $result, $tag ) {
$type = $tag[‘type’];
$name = $tag[‘name’];if ( ‘newsletter’ == $name ) {
$subscribe = isset($_POST[$name]);
if(function_exists(‘mymail’) && $subscribe){
$userdata = array(
’email’ => $_POST[’email’],
‘firstname’ => $_POST[‘firstname’],
‘lastname’ => $_POST[‘lastname’],
);
$list_ids = array(123, 456); // your list ids
$overwrite = true;
$subscriber_id = mymail(‘subscribers’)->add($userdata, $overwrite);
if(!is_wp_error($subscriber_id)){
mymail(‘subscribers’)->assign_lists($subscriber_id, $list_ids);
}
}
}return $result;
}
add_filter( ‘wpcf7_validate_checkbox’, ‘wpcf7_my_validate’, 10, 2 );function getRefererPage( $form_tag )
{
if ( $form_tag[‘name’] == ‘referer-page’ ) {
$form_tag[‘values’][] = $_SERVER[‘HTTP_REFERER’];
}
return $form_tag;
}
if ( !is_admin() ) {
add_filter( ‘wpcf7_form_tag’, ‘getRefererPage’ );
}Im slowly progressing. Thanks. i just need to figure this code out.
September 29, 2014 at 5:39 pm #115622My child theme is not functioning right….
http://s28.postimg.org/79n5et6x9/child_theme_is_not_functioning_right.pngCSS STYLE FILE I PUT
/* LICENSE & DETAILS
==================================================
Theme Name: Neighborhood
Theme URI: http://neighborhood.swiftideas.net
Description: A Retina Responsive Multi-Purpose WordPress Theme – Designed & Developed by Swift Ideas ( http://www.swiftideas.net )
License: GNU General Public License version 3.0
License URI: http://www.gnu.org/licenses/gpl-3.0.html
Version: 1.93
Author: Swift Ideas
Author URI: http://www.swiftideas.net
Template: neighborhood
All files, unless otherwise stated, are released under the GNU General Public License
version 3.0 (http://www.gnu.org/licenses/gpl-3.0.html)
==================================================
*/
@import url(“../neignborhood/style.css”);
September 30, 2014 at 2:23 am #115685BTW, can the Mymail snippet can be converted as a plugin? instead of making the child theme? my theme breaks when i activate the child theme.
September 30, 2014 at 5:32 am #115700Hi,
You can use it as a plugin. Please refer this article http://www.hongkiat.com/blog/beginners-guide-to-wordpress-plugin-development/ to make the plugin as you want.
Thanks 🙂
With Best Regards
MohammadSeptember 30, 2014 at 5:50 am #115706Thank, you so. I already went and did the following.
here’s the code
<?php // Opening PHP tag – nothing should be before this, not even whitespace
/*
Plugin Name: mymail-contact
Plugin URI: crestviewphotography.com
Description: Mymail
Author: Jasper
Author URI: http://net.tutsplus.com
Version: 1.0
/*
/*
* requires a checkbox with the the name “newsletter” in your CF7
*/
function wpcf7_my_validate( $result, $tag ) {
$type = $tag[‘type’];
$name = $tag[‘name’];if ( ‘newsletter’ == $name ) {
$subscribe = isset($_POST[$name]);
if(function_exists(‘mymail’) && $subscribe){
$userdata = array(
’email’ => $_POST[’email’],
‘firstname’ => $_POST[‘firstname’],
‘lastname’ => $_POST[‘lastname’],
);
$list_ids = array(123, 456); // your list ids
$overwrite = true;
$subscriber_id = mymail(‘subscribers’)->add($userdata, $overwrite);
if(!is_wp_error($subscriber_id)){
mymail(‘subscribers’)->assign_lists($subscriber_id, $list_ids);
}
}
}return $result;
}
add_filter( ‘wpcf7_validate_checkbox’, ‘wpcf7_my_validate’, 10, 2 );function getRefererPage( $form_tag )
{
if ( $form_tag[‘name’] == ‘referer-page’ ) {
$form_tag[‘values’][] = $_SERVER[‘HTTP_REFERER’];
}
return $form_tag;
}
if ( !is_admin() ) {
add_filter( ‘wpcf7_form_tag’, ‘getRefererPage’ );
}the problem i have is identifying what are the elements into the code. for example, what are those values the codes i bold. I’ve attach the codes i have. I need a little direction here.
Attachments:
You must be logged in to view attached files.September 30, 2014 at 5:53 am #115712would this be the right approach? I know making a plugin would take so much if i want it robust, but this is very specific and selective.
September 30, 2014 at 7:28 am #115728Hi,
It will work as you desire. So use without hesitation.
Thanks
Mohammad -
Posted in: Neighborhood
You must be logged in and have valid license to reply to this topic.