latest stable versions: v150827 (changelog)

Old Forums (READ-ONLY): The community now lives at WP Sharks™. If you have an s2Member® Pro question, please use our new Support System.

registration welcome email hook

Home Forums Community Forum registration welcome email hook

This topic contains 6 replies, has 3 voices. Last updated by  Jason (Lead Developer) 3 years, 10 months ago.

Topic Author Topic
Posted: Wednesday Jan 30th, 2013 at 1:13 am #39970

hi,

i’ve tried to create a hook for the registration welcome email but it didn’t seem to work for me.
i managed to get the paypal payment confirmation email, but not the registration.
i’m also wondering about the var array attributes. what attributes does it have, is there a list i can preview?

this is my current code that doesn’t work, i’m not sure it gets triggered at all. getting the signup email hook working gave me the impression that it is sitting at the right place in my s2-hacks.php file.

add_filter ("ws_plugin__s2member_registration_notification_email_sbj", "my_s2_registeration_sbj", 10, 2);
function my_s2_registeration_sbj ($s2member_default_sbj, $vars = array ())
{
	print_r($vars);
 	file_put_contents(WP_CONTENT_DIR."/debug.log", var_export($vars, true));

    return "testing registeration email subject";
}
add_filter ("ws_plugin__s2member_registration_notification_email_msg", "my_s2_registeration_msg", 10, 2);
function my_s2_signup_msg ($s2member_default_msg, $vars = array ())
{
	print_r($vars);
 	file_put_contents(WP_CONTENT_DIR."/debug.log", var_export($vars, true));
 	
    return "Thank you! You purchased:n" . $vars . "nnPlease register now:n" . add_query_arg("action", "register", wp_login_url ());
}

this is the code for the signup that did work:

add_filter ("ws_plugin__s2member_signup_email_sbj", "my_s2_signup_sbj", 10, 2);
function my_s2_signup_sbj ($s2member_default_sbj, $vars = array ())
{
    return "Congratulations ( your account has been approved )";
}
add_filter ("ws_plugin__s2member_signup_email_msg", "my_s2_signup_msg", 10, 2);
function my_s2_signup_msg ($s2member_default_msg, $vars = array ())
{
    return "Thank you! You purchased:n" . $vars["paypal"]["item_name"] . "nnPlease register now:n" . add_query_arg("action", "register", wp_login_url ());
}
  • This topic was modified 3 years, 11 months ago by  Bruce. Reason: Formatting

List Of Topic Replies

Viewing 6 replies - 1 through 6 (of 6 total)
Author Replies
Author Replies
Posted: Wednesday Jan 30th, 2013 at 1:14 am #39971

sorry i also forgot to mention.
i’d like to be able to put a condition for one of my Custom Registration/Profile Fields.
it’s a select dropdown.

Posted: Friday Feb 1st, 2013 at 9:28 pm #40324
Bruce
Username: Bruce
Staff Member

this is my current code that doesn’t work, i’m not sure it gets triggered at all. getting the signup email hook working gave me the impression that it is sitting at the right place in my s2-hacks.php file.

That code looks correct to me. I would suggest instead using update_option() to store the information.

See: WordPress -> update_option()

Unfortunately, as stated in our Support Policy, we cannot debug custom code. If you’re having issues, we recommend posting a job listing in a site such as http://elance.com/ or http://jobs.wordpress.net/.

i’d like to be able to put a condition for one of my Custom Registration/Profile Fields.
it’s a select dropdown.

This is not something s2Member currently supports natively. If this feature is something that you need, I’d recommend using custom JavaScript code to do this. s2Member assigns IDs to each of your Custom Profile/Registration Fields when it generates them so that something like this is possible. You can find the IDs for your Custom Profile/Registration Fields by examining the source code of the page in which your signup form is on with something like Firebug for Firefox.

Posted: Tuesday Feb 12th, 2013 at 11:20 pm #41594

i just want to be able to get the hook working.
my next option is to use the built in wordpress ones but i’d like to be able to keep it consistent.
i really need help with this, i’ve been investing a lot of time. i don’t need help with the programming as much as i do with just getting the hook from the plugin to trigger.

i tried to put a mail function within the hook to see if i can get it to trigger anything but i believe it’s not being called.
the emails are configured to use the s2member emails overridding the wordpress ones.

this is the code i have within my s2-hacks.php within mu-plugins

add_filter (“ws_plugin__s2member_registration_notification_email_sbj”, “my_s2_registeration_sbj”, 10, 2);
function my_s2_registeration_sbj ($s2member_default_sbj, $vars = array ())
{
wp_mail(‘testemail’, ‘subject triggered’, ‘subject triggered’, $headers);
return “testing registeration email subject”;
}
add_filter (“ws_plugin__s2member_registration_notification_email_msg”, “my_s2_registeration_msg”, 10, 2);
function my_s2_registeration_msg ($s2member_default_msg, $vars = array ())
{
wp_mail(‘testemail’, ‘body text triggered’, ‘body text triggered’, $headers);
return “testing registeration email body text”;
}

Posted: Friday Feb 15th, 2013 at 2:55 am #41787
Staff Member

This code sample you posted previously is very close. However, one of your functions has the wrong name here.

function my_s2_signup_msg should be: my_s2_registeration_msg

Or maybe: my_s2_registration_msg

Very close. Looks pretty good overall. If you want to inspect the $vars array, you can check the debug.log file for all of the array keys this variable contains. In the functions below, you are logging this data already.

add_filter ("ws_plugin__s2member_registration_notification_email_sbj", "my_s2_registeration_sbj", 10, 2);
function my_s2_registeration_sbj ($s2member_default_sbj, $vars = array ())
{
	print_r($vars);
 	file_put_contents(WP_CONTENT_DIR."/debug.log", var_export($vars, true));

    return "testing registeration email subject";
}
add_filter ("ws_plugin__s2member_registration_notification_email_msg", "my_s2_registeration_msg", 10, 2);
function my_s2_signup_msg ($s2member_default_msg, $vars = array ())
{
	print_r($vars);
 	file_put_contents(WP_CONTENT_DIR."/debug.log", var_export($vars, true));
 	
    return "Thank you! You purchased:\n" . $vars . "\n\nPlease register now:\n" . add_query_arg("action", "register", wp_login_url ());
}

In this code sample you posted, you are sending email (which you won’t want to do on a live site).
You probably know this already, but just to point this out. These are filters, not actions. You simply return the custom email subject and message body.

add_filter (“ws_plugin__s2member_registration_notification_email_sbj”, “my_s2_registeration_sbj”, 10, 2);
function my_s2_registeration_sbj ($s2member_default_sbj, $vars = array ())
{
wp_mail(‘testemail’, ‘subject triggered’, ‘subject triggered’, $headers);
return “testing registeration email subject”;
}
add_filter (“ws_plugin__s2member_registration_notification_email_msg”, “my_s2_registeration_msg”, 10, 2);
function my_s2_registeration_msg ($s2member_default_msg, $vars = array ())
{
wp_mail(‘testemail’, ‘body text triggered’, ‘body text triggered’, $headers);
return “testing registeration email body text”;
}

If these Filters are not working during test transactions, please be sure that you are actually registering for a new account, and not modifying an existing one. There are two additional filters against a short modification email that s2Member sends as well. You can look these up in the s2Member source code if you like.

ws_plugin__s2member_modification_notification_email_sbj
ws_plugin__s2member_modification_notification_email_msg
Posted: Wednesday Feb 20th, 2013 at 11:31 pm #42633

i’m still getting the same message i had setup in the new user email configuration (yes customise new user emails with s2member) in the general options.
here’s my m-plugins s2-hacks.php

add_filter ("ws_plugin__s2member_registration_notification_email_sbj", "my_s2_registeration_sbj", 10, 2);
function my_s2_registeration_sbj ($s2member_default_sbj, $vars = array ())
{
	print_r($vars);
	file_put_contents(WP_CONTENT_DIR."/debug.log", var_export($vars, true));
	return "testing registeration email subject";
}
add_filter ("ws_plugin__s2member_registration_notification_email_msg", "my_s2_registeration_msg", 10, 2);
function my_s2_registeration_msg ($s2member_default_msg, $vars = array ())
{
	print_r($vars);
	file_put_contents(WP_CONTENT_DIR."/debug.log", var_export($vars, true));
	return "testing registeration email body text";
}


add_filter ("ws_plugin__s2member_modification_notification_email_sbj", "my_s2_modification_sbj", 10, 2);
function my_s2_modification_sbj ($s2member_default_sbj, $vars = array ())
{
	print_r($vars);
	file_put_contents(WP_CONTENT_DIR."/debug.log", var_export($vars, true));
	return "testing registeration email subject";
}
add_filter ("ws_plugin__s2member_modification_notification_email_msg", "my_s2_modification_msg", 10, 2);
function my_s2_modification_msg ($s2member_default_msg, $vars = array ())
{
	print_r($vars);
	file_put_contents(WP_CONTENT_DIR."/debug.log", var_export($vars, true));
	return "testing registeration email body text";
}

fyi i ensured that the write debug.log is working running it outside the filter and it was writing to the file fine.

Posted: Saturday Feb 23rd, 2013 at 7:30 am #43000
Staff Member

Thanks for the follow-up :-)

That’s about as far as I can go on custom coding. I’ll be happy to provide you with more leads on where to find certain things, or to share ideas with you, but I can’t debug any custom code that you end up with; due to time constraints :-) Please see: s2Member® » Support Policy » Within Scope for some clarification on this. Thanks!

Also, I just want to update you on a recent development in s2Member. The latest release of s2Member makes it possible to introduce PHP tags of your own into email messages; making several hacks like this obsolete. Please see: s2Member® Unified Changelog » v130220
Viewing 6 replies - 1 through 6 (of 6 total)

This topic is closed to new replies. Topics with no replies for 2 weeks are closed automatically.

Old Forums (READ-ONLY): The community now lives at WP Sharks™. If you have an s2Member® Pro question, please use our new Support System.

Contacting s2Member: Please use our Support Center for bug reports, pre-sale questions & technical assistance.