Page 1 of 1

Customer info in URL of email

PostPosted: December 23rd, 2011, 12:51 am
by einstein101
I'm sending the auto email to new customers in s2member pro. In the email I need to include a url to another domain with all the information of the customer.

Below is the link I have set-up in "New User Email Message" section of s2member

Register for course: https(colon)//www(dot)anotherdomain.com/mycompany/orderxfer.asp?LS_StudentID=%%user_id%%&FirstName=%%user_first_name%%&LastName=%%user_last_name%%&Company=%%Company%%&Address=%%Address%%&City=%%City%%&State=%%State%%&Zip=%%Zip%%&Telephone=%%Phone%%&Password=%%user_pass%%&OrderID=%%OrderID%%&PackageIDs=%%PackageID%%

Example:
https(colon)//www(dot)anotherdomain.com/mycompany/orderxfer.asp?LS_StudentID=13&FirstName=John&LastName=Doe&Company=Exec&Address=15145 (HERE IS THE SPACE WHERE THE HOTLINK STOPS. EVERYTHING AFTER IS NOT LINKED) Western Ave&City=Orlando&State=FL&Zip=32837&Telephone=888 888 8888&Password=xxxxxx&OrderID=00000008&PackageIDs=5456456


The problem occurs after the number in the address field. It has a space before the street name and the hotlink of the url stops. I need it to include all the information. How can I get this to work?



Thanks in advance.

Re: Customer info in URL of email

PostPosted: December 23rd, 2011, 2:52 pm
by Raam Dev
Hi einstein101,

What you need is to URL Encode the entire URL, so that spaces are converted to characters that are allowed in a URL (e.g., the URL code for a space is %20).

To do that you'll need to use the PHP Function urlencode(), however you cannot use PHP in the s2Member Email Configuration panel.

So, what you'll need to do is use the s2-hacks.php file to recreate the new customer email and build the email using a PHP function instead (all of this is described here: http://www.primothemes.com/forums/viewt ... nal#p33365).

Then, when you build your URL and save it all into a variable, you'll do something like this before including it in the body of the email message:

Code: Select all
$url = urlencode($url); 


That will convert any spaces in the URL to the special characters that are allowed and interpreted by the browser.

Does that make sense?

Re: Customer info in URL of email

PostPosted: December 26th, 2011, 2:15 pm
by einstein101
I'm really confused on how this will be done. Sorry. I have the s2-hacks.php file and the sample code in place.


<?php 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"]["user_id"]["user"]["user_pass"] . "\n\nPlease register now:\n" . add_query_arg("action", "register", wp_login_url ()); }

$url = (urlencode($vars["paypal"]["item_name"]["user_id"]["user"]["user_pass"]);
echo $url;
?>

Question: How do I create the url using the variables I have above such as [user_id][user_pass]?

Question: How do I tell the s2 program to use this instead of the original email for new user accounts?

Thanks so much! I apologize for being so ignorant on all this ---

Re: Customer info in URL of email

PostPosted: December 27th, 2011, 4:07 pm
by Raam Dev
Hi einstein101,

You're using the variables incorrectly. You must use $vars["user"], $vars["user_id"], etc.

If you're not familiar with PHP variables and arrays, please see PHP Variables and PHP Array to learn more. The modifications you're trying to make require a basic understanding of the PHP language and without that it will be difficult to make the modifications. You may also want to read this primer on Hooks/Filters for WordPress/s2Member.

Also, keep in mind that certain information will not be available in the Signup Confirmation email (ws_plugin__s2member_signup_email_msg). The Signup Confirmation email is designed to send the registration link to the user after making a purchase so that the user can register for an account.

When that email gets sent, the user hasn't yet registered, so you won't be able to get things like First Name, Last Name, etc. That also means you won't have access to any of the necessary Custom Fields that you need to build your other registration link at that point.

I think what you probably want to modify is the New User Notification email. Modifying that email requires redefining the wp_new_user_notification() WordPress function. This post shows how that's done with a plugin.

Also, please see WP Admin -> s2Member -> API/Scripting -> S2MEMBER_CURRENT_USER_FIELDS to understand how you can retrieve specific s2Member Custom Fields.