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.

populate custom fields in gravity forms

Home Forums Community Forum populate custom fields in gravity forms

Tagged: 

This topic contains 3 replies, has 2 voices. Last updated by  Raam Dev 4 years, 10 months ago.

Topic Author Topic
Posted: Tuesday Feb 21st, 2012 at 12:21 pm #5882
Will
Username: paintscape

I have a custom s2member field called “RID” that I would like to add to a gravity form. I would like to add the field as a hidden field that dynamically populates. I would like it to be listed along with name, date, email and the completed form fields. Gravity Forms says “You would do this using custom PHP and the gform_field_value filter hook.” I would add it to the functions.php, then it would be listed as an option for the hidden fields in gravity forms.

Example:

In my case the s2member field id is “rid”

I looked at the old forums and found a post that related to this issue but the content was no longer available…

Thanks,
Will

List Of Topic Replies

Viewing 3 replies - 1 through 3 (of 3 total)
Author Replies
Author Replies
Posted: Wednesday Feb 22nd, 2012 at 2:57 pm #6001
Raam Dev
Username: Raam
Staff Member

Hi Will,

Please see this thread on the old forum regarding extracting s2Member Custom Fields using PHP:
http://www.primothemes.com/forums/viewtopic.php?f=4&t=15658#p48878

Posted: Wednesday Feb 22nd, 2012 at 4:24 pm #6014
Will
Username: paintscape

Thanks for the reply and it does hint at what I need but isn’t really the answer. l think I need to be more specific.

Here is what gravity forms says about adding a custom field as I would like to do it…

In order to use this hook you must do the following:

– Edit your Form
– Add a hidden field you want to populate and give it a name
– Edit the hidden field
– Select the Advanced tab
– Select the “Allow field to be populated dynamically” checkbox
– Give the field a parameter name, this parameter name is used to target the field so name it something simple like “email” or something similar.
– Save your form

Then you would use the gform_field_value hook by adding custom code in your themes functions.php file to dynamically populate that field. For example, if you set the parameter to “email” your code would look like this:

In my case I need to populate a s2member_custom_fields called “rid” as a hidden field in a form. Then I can export the data (from Gravity Forms) for all users that filled in that form within a date range. In other words, I need to add the s2member custom field “RID” for a user logged in and filling in the form. Then at a later date it will be available as one of the fields I can export.

From the old forum post, it looks like I need to pull this s2member_custom_field using MySQL REGEXP operator and it looks complicated.

Posted: Thursday Feb 23rd, 2012 at 1:45 pm #6138
Raam Dev
Username: Raam
Staff Member

Hi Will,

Yes, unfortunately extracting s2Member custom field data from the database is complicated. Here’s what Jason, the lead developer, wrote on this topic:

Yes, you’re running into a known design flaw within s2Member. s2Member was designed to store all Custom Registration/Profile Fields configured with s2Member, into a serialized array in the wp_usermeta table, under the meta_key wp_s2member_custom_fields.

While this DOES have some nice advantages, it unfortunately has many disadvantages too. In your case, you’re seeing that it’s difficult to search your MySQL database for specific information in these fields, because they’re all globbed together into one serialized array, stored with key wp_s2member_custom_fields.

We are planning to address this issue in a future release of s2Member, in a way that preserves backward compatibility. Until then, if you need to search your MySQL database in this way, I suggest using the MySQL REGEXP operator.

He shares code examples in that thread to explain how to do that.

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.