PriMoThemes — now s2Member® (official notice)

This is now a very OLD forum system. It's in READ-ONLY mode.
All community interaction now occurs at WP Sharks™. See: new forums @ WP Sharks™

Change profile custom fields values

s2Member Plugin. A Membership plugin for WordPress®.

Change profile custom fields values

Postby rvencu » January 31st, 2012, 3:13 pm

Hi, I use some custom registration / profile fields. I need to use an algorithm to generate several fields content and I do not want the user to insert the values manually (still the user must see the field content).

I can generate in PHP the required value. How do I interact with the profile updates?

I found several hooks but have no idea how to change the value captured from the form into the custom value I calculate for the custom field.
User avatar
rvencu
Registered User
Registered User
 
Posts: 7
Joined: October 25, 2011

Re: Change profile custom fields values

Postby Raam Dev » January 31st, 2012, 6:35 pm

Hello,

This thread may be useful: viewtopic.php?f=4&t=16594#p59823
Raam Dev || Wherever you are, be there. || Please rate s2Member!
User avatar
Raam Dev
Developer
Developer
 
Posts: 810
Joined: October 26, 2011

Re: Change profile custom fields values

Postby rvencu » February 1st, 2012, 5:29 am

Yes, I have been there with no success. I tried to hook into those functions but how do I change the value of a field in my action before the field gets updated to the database. What is the syntax?
User avatar
rvencu
Registered User
Registered User
 
Posts: 7
Joined: October 25, 2011

Re: Change profile custom fields values

Postby rvencu » February 1st, 2012, 8:49 am

After experimenting with the hooks I discovered some things. Nothing seems to be helpful.
Since I need to alter values in variables it seems that I must use filters. I tried this code:

Code: Select all
add_filter ("ws_plugin__s2member_during_profile_during_fields_display_custom_fields", "my_function");
function my_function ($bool, $vars = array ())
    {
        var_dump($vars);
      return $vars;
    }


So I discovered that in all filter hooks I only get empty array as $vars:
Code: Select all
array(0) { }
Therefore what is the purpose of these filters?

In actions it is true, I get a lot of things inside $vars variable but how to handle them? Specifically what can I do to save a certain value to a certain custom field inside an action?
User avatar
rvencu
Registered User
Registered User
 
Posts: 7
Joined: October 25, 2011

Re: Change profile custom fields values

Postby Jason Caldwell » February 6th, 2012, 3:05 pm

Thanks for the heads up on this thread.

I would suggest this article to you as a primer as Hooks/Filters for WordPress.
http://codex.wordpress.org/Plugin_API#H ... our_Filter

The reason you're getting an empty array is because you're only requesting one function argument.

Try it like this please.
Code: Select all
add_filter ("ws_plugin__s2member_during_profile_during_fields_display_custom_fields", "my_function", 10, 2);
function my_function ($bool, $vars = array ())
    {
        var_dump($vars);
      return $vars;
    } 
~ Jason Caldwell / Lead Developer
& Zeitgeist Movie Advocate: http://www.zeitgeistmovie.com/

Is the s2Member plugin working for you? Please rate s2Member at WordPress.org.
You'll need a WordPress.org account ( comes in handy ). Then rate s2Member here Image
.
User avatar
Jason Caldwell
Lead Developer
Lead Developer
 
Posts: 4045
Joined: May 3, 2010
Location: Georgia / USA


Return to s2Member Plugin

Who is online

Users browsing this forum: No registered users and 0 guests