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.

Hidden Field for capturing referral source

Home Forums Community Forum Hidden Field for capturing referral source

This topic contains 5 replies, has 2 voices. Last updated by  Bruce 3 years, 8 months ago.

Topic Author Topic
Posted: Monday Apr 29th, 2013 at 11:38 am #48655

I basically want to capture the http referrer string upon user registration; using either a hidden field, or whatever. So I can use the backend of my s2member as a sort of jimmy rigged crm.

List Of Topic Replies

Viewing 5 replies - 1 through 5 (of 5 total)
Author Replies
Author Replies
Posted: Tuesday Apr 30th, 2013 at 3:24 am #48781
Bruce
Username: Bruce
Staff Member

Thank you for your inquiry.

I went over this in this post:

http://www.s2member.com/forums/topic/hidden-custom-field-to-store-affiliate-id/#post-48777

Posted: Tuesday Apr 30th, 2013 at 12:23 pm #48801

I’m not experienced enough to take all the logic that you’ve laid out, and apply it to my example. In theory, I understand that:
1. I need to set up a url that has the variable I’m trying to capture
2. I need some way to attach those variables to a user’s profile

Now for my specific situation, I’ve found a script that takes the utmz cookie in google analytics, and parses out all the different variables (like referring domain, keyword, medium, source) , listed here:

<?php
//DEFINE COOKIE DOMAIN, ALLOWS SCRIPT TO BE USED ACROSS MULTIPLE DOMAINS
$domain = $_SERVER['SERVER_NAME'];
$domain = "." . ltrim($domain,"www.");

// SET COOKIES FROM GOOLGE-ANALYTICS COOKIE
$info = $_COOKIE['__utmz'];
// Get rid of id stuff
$holder = split("u", $info, 2);
$string = "u" . $holder[1];
// Parse String
$ga_vars = split("\|", $string);
foreach ($ga_vars as $var) {
list($key,$value) = split("=",$var);
if ($key == "utmcmd") { setcookie("Medium", $value, time()+100000000, "/", $domain); $medium = $value; }
if ($key == "utmctr") { setcookie("Keywords", $value, time()+100000000, "/", $domain); $keywords = $value; }
if ($key == "utmcsr") { setcookie("GAsource", $value, time()+100000000, "/", $domain); $gasource = $value; }
}

// SET REFERRING URL
if (!isset($_COOKIE['Referer'])) {
setcookie("Referer", $_SERVER['HTTP_REFERER'], time()+10000000, "/", $domain);
$referurl = $_SERVER['HTTP_REFERER'];
} else { $referurl = $_COOKIE['Referer']; }

// SET FORM_URL VALUE
$formurl = "http://".$_SERVER['HTTP_HOST'].$_SERVER['REQUEST_URI'];

// SET LANDING PAGE
if (!isset($_COOKIE['LandingPage'])) {
setcookie("LandingPage", "http://".$_SERVER['HTTP_HOST'].$_SERVER['REQUEST_URI'], time()+10000000, "/", $domain);
$landingpage = "http://".$_SERVER['HTTP_HOST'].$_SERVER['REQUEST_URI'];
} else { $landingpage = $_COOKIE['LandingPage']; }
?>

So I imagine that there is some way for me to somehow grab the variables from the code above, and display them in my user list in the admin dashboard as another column of information. But I have no idea how that would work.

Posted: Tuesday Apr 30th, 2013 at 10:29 pm #48874
Bruce
Username: Bruce
Staff Member

1. I need to set up a url that has the variable I’m trying to capture
2. I need some way to attach those variables to a user’s profile

If you have to store this information, then this video will be of use to you:

Video » s2Member (Custom Fields Dynamically?)

Posted: Wednesday May 1st, 2013 at 12:23 pm #48931

Ok, this is my current assumption for what I need to do:

1. Create a custom hack to pull in dynamic information and store it in a custom registration field. I believe I have that one 90% figured out. I created an ‘s2hacks.php’ file, stored it under /mu-plugins/, and inserted the following code:

<?php
add_action("ws_plugin__s2member_before_custom_field_gen", "my_dynamic_field_options");
function my_dynamic_field_options ($vars = array ())
{
    $_field = &$vars["_refs"]["_field"];
    if ($_field["id"] === "lead_source")
        {
            $_field["options"] = //I have no idea what to put here. Some variable from my google parser script?
            
        }    
         
}
?>

2. I created a custom registration field, with the id of ‘lead_source’
3. I don’t know how to hide that field from the registration form yet, but I should be able to figure it out.
4. What I don’t know how to do is take the variables from my google parser script above, and feed them into the ‘lead_source’ field in my s2hacks.php file.

Posted: Thursday May 2nd, 2013 at 12:38 am #48989
Bruce
Username: Bruce
Staff Member

4. What I don’t know how to do is take the variables from my google parser script above, and feed them into the ‘lead_source’ field in my s2hacks.php file.

You could try saving the data you take from that script, and save it into the global scope, then get it in this script if you have to.

See: PHP Globals

That’s about as far as we can go with custom code. If you need further assistance, we recommend http://jobs.wordpress.net, or another freelance web site where WordPress® experts are offering their expertise through a bid on your project.
Viewing 5 replies - 1 through 5 (of 5 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.