Ask your WordPress questions! Pay money and get answers fast! Comodo Trusted Site Seal
Official PayPal Seal

Contact Form 7 + Wysija WordPress

  • SOLVED

I need to add the user email on Wysija from my contact form, thats on extension called Contact Form 7.

Wysija sent me this instructions:
http://support.wysija.com/knowledgebase/plugin-form-integrate/

I need to add that on my Contact Form 7.

Thats it.

Answers (1)

2013-04-09

Christianto answers:

Hello,

Please try this..
function wysija_contactform7_subscribe($cfdata) {
$formdata = $cfdata->posted_data;

/*
if you use different name/id attribute for CF7
please change 'your-name' and 'your-email'
*/
$user_name = $formdata['your-name'];
$user_email = $formdata['your-email'];

/*
change this according to your user list id you want this user to subscribe,
*/
$listID = array( 'my_list_ID_1', 'my_list_ID_2' );

$userData=array(
'email' => $user_email,
'firstname' => $user_name
);
$data=array(
'user' => $userData,
'user_list' => array( 'list_ids'=> $listID )
);
$userHelper=&WYSIJA::get('user','helper');
$userHelper->addSubscriber($data);
}
add_action('wpcf7_mail_sent', 'wysija_contactform7_subscribe', 1);


above will run if mail successfully sent,
please edit your list ID that you need user to subscribe and your $formdata to match name/id on your cf7 generated form.

let me know if this not working..
Thanks


business_ideas comments:

Hey man! Looks AWSOME! Exactly what I needed! I added the last name.

The only thing that is not working is the list ID

I changed the line to: $listID = array('Contatos');

Didnt work. The list name is 'Contatos'.


Christianto comments:

it could be case sensitive, have you try with all lowercase letter?
$listID = array('contatos');

or you could print all list id and name to check it:
function print_wysija_listid(){
$modelList = &WYSIJA::get('list','model');
$wysijaLists = $modelList->get(array('name','list_id'));
foreach($wysijaLists as $list){
echo 'list id : '.$list['list_id'].' , list name : '.$list['name'] ."<br/>";
}
}
print_wysija_listid();


business_ideas comments:

Where do I put this print code?

I tried Contatos and contatos. Didnt work. The C is in upper case though. So I dont get what is happening... Thats the only thing missing...