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.

Default values for hidden profile fields

Home Forums Community Forum Default values for hidden profile fields

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

Topic Author Topic
Posted: Thursday Apr 25th, 2013 at 1:37 pm #48385

We’re using an obfuscated free sign-up page for our site, but we have people registering in cohorts, and we’d like to distinguish them. Is it possible to pass values for hidden profile fields (which we already have, and use when importing users) via URL parameters? i.e., we’d like to send the following link to our first cohort:

http://www.site.com/230482031?cohort=1

and then this link to the second group:

http://www.site.com/230482031?cohort=2

and have that parameter stored in their profile – this is important for Mailchimp integration, so we can segment the resulting list for emails later on. I don’t think default field values will work, as they need to be per group, not even per form. Another solution might be to have a different signup form for future groups, but (a) that will create a mess of WP pages with random names, and (b) I’m not even sure we could customise profile fields with the form shortcode anyway. The parameter approach seems much simpler… But is it possible?

Thanks,

David.

List Of Topic Replies

Viewing 3 replies - 1 through 3 (of 3 total)
Author Replies
Author Replies
Posted: Friday Apr 26th, 2013 at 3:39 am #48444
Bruce
Username: Bruce
Staff Member

Thank you for your inquiry.

This video should give you what you need.

Video » s2Member (Custom Fields Dynamically?)

Posted: Friday Apr 26th, 2013 at 10:56 am #48496

Thanks – I think I’ve got what I need working now. I’ve got a function which already checks various profile fields for default values hooked against the ws_plugin__s2member_during_configure_user_registration_front_side action. I’ve added the following at the beginning of that function:

foreach ($_GET as $k => $v) {
	$cFields[$k] = $v;
}

The array $cFields[] is then merged back into the users profile with a call to array_merge() and update_user_option().

So now I can put any combination of profile fields in the URL as parameters. However, this looks like a recipe for injection attacks! I’m wondering what the best way to defend this might be…

Is there a way of getting an array of the current valid profile fields, so I can restrict processing to only those fields? Is there anything else I should be doing to minimise the risk of people putting random code into the URL?

Posted: Friday Apr 26th, 2013 at 10:21 pm #48527
Bruce
Username: Bruce
Staff Member

So now I can put any combination of profile fields in the URL as parameters. However, this looks like a recipe for injection attacks! I’m wondering what the best way to defend this might be…

The best thing to do here would be to only allow the specific field you’re looking to have available for Users to change to be changed via your script. You’ll want to only check for that specific $_GET variable and only array_merge() in that value.

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