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.

Custom field variable?

Home Forums Community Forum Custom field variable?

This topic contains 7 replies, has 2 voices. Last updated by  Raam Dev 4 years, 1 month ago.

Topic Author Topic
Posted: Sunday Nov 4th, 2012 at 3:34 am #30577

Hi,

I have made my own little cookie tracking affiliate code plug-in for WordPress. It is to track who refers free sign-ups to my website.

I have seen the video tutorial on creating a s2-hacks.php file for country codes and I have completed that ok.

Now what I need to do is instead of having a pre-populated drop down menu for countries, I need to be able to enter a single custom field for the referrer ID, derived from the variable I have already stored as a cookie. I am struggling both on calling the cookie as a variable in to the hacks file and also working out what the parameter for my new custom field should be. In the countries example it is called “options”. But I do not want options. Now I want one field entry for the affiliate ID basically. So that when A new person registers with the affiliate code, I have already managed to generate, then it pre-fills in the registration field with a meta entry for the affiliates ID.
Example: $aid = $_COOKIE[“AffiliateCookie”];

I tried to change the hack file for the country codes by making single line one with $aid, the variable I tried to define from the cookie, but I don’t think the cookie is being called properly in the code and also I have a drop down menu now with a blank entry.

Obviously I need to have a single custom field for affiliate Id but what would the field be called? Its obviously not “options”? And also how to properly define the variable from the cookie in the hack file please?

Hope that makes sense. Been trying to do this for 24 hours without sleep now.

Thanks in advance for any help.

~Gary.

List Of Topic Replies

Viewing 7 replies - 1 through 7 (of 7 total)
Author Replies
Author Replies
Posted: Monday Nov 5th, 2012 at 5:26 pm #30688
Raam Dev
Username: Raam
Staff Member

Hi Gary,

It sounds like you’re just trying to have a Custom Profile/Registration field show up on the Pro-Form with its value prefilled with a value from the cookie on the person’s computer (if any), is that right? If so, the easiest way to achieve that would be to create your Custom Registration Field, display the Pro-Form, then view-source, and then copy the HTML for that specific field.

Then, you can edit the Pro-Form template (see Is it possible to modify s2Member® Pro Form templates?), paste in that HTML, then add some PHP that echo’s the value of $_COOKIE[“AffiliateCookie”] into the field.

Since you’ll be adding this field to the Pro-Form manually, you’ll then need to edit the Field’s properties inside s2Member and set it to be hidden during registration (otherwise two copies of the field will show up on the Pro-Form).

Posted: Wednesday Nov 7th, 2012 at 3:03 am #30857

Ok thanks. I was starting to do it that way but I only copied the generated HTML and the form wouldn’t send.

I will try editing the template to see if that will allow it to send.

Where is that page on here where you describe hiding a form field using CSS please?

Thanks.

Posted: Wednesday Nov 7th, 2012 at 5:54 pm #30944
Raam Dev
Username: Raam
Staff Member

I’m not sure which page you’re referring to (maybe this one?), but it should be as simple as doing “View Source” on the page, locating the field you want to hide, then finding its CSS id and adding a #css-id-name { display: none; } to your CSS file.

Posted: Friday Nov 9th, 2012 at 5:45 am #31117

Ok thanks for that. Sorry for being vague at times.

One challenge though. When I put the DIV for the field, copied from the generated form output HTML, inside the template file. It messes up the WordPress page with my form on it. Any solution come to mind for that please? Or is that not an s2Member issue? If not fair enough.

Posted: Friday Nov 9th, 2012 at 5:47 am #31118

Sorry my bad. That was just a stray DIV tag. Will report back once I have your method fully working or if I need any more help. Cheers.

Posted: Friday Nov 9th, 2012 at 7:55 am #31124

Ramm,

That worked like a dream, my friend.

Thank you.

Posted: Friday Nov 9th, 2012 at 12:23 pm #31147
Raam Dev
Username: Raam
Staff Member

Glad I could help, Gary! :)

Viewing 7 replies - 1 through 7 (of 7 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.