I created some custom fields to register more information of a user than WP-standard. Next to S2 I use Gravity forms to enable memebers to subscribe to our events. Therefor I want to retrieve content from the S2 Custom Fields and prefill that information in Gravity Form Form-fields.
In Gravity Forms I can use some types of fields; name etc are standard and I can use {user:first_name} to prefill the dedicated field in Gravity. In a HTML-block I can also retrieve and publish via [S2Get user_field=âcolor-of-my-hairâ], but I cannot use this in the other Gravity Field types.
Anyone who can help me?
Custom fields in Gravity Forms form-fields
In the meantime I made some progress. I can publish a literal in the GF-field via a small piece of coding.
add_filter( âgform_field_value_streetname-1â, âpopulate_streetnameâ );
function populate_streetname( $value ) {
return âAngel hill roadâ;
}
Now this is part of the solution. The other part is to retrieve the custom field content of the logged on user.
someting like: $street=get_user_field(street)
Is such simple item available this way?
Hi Leon,
Maybe this will work for you:
$custom_fields = get_user_option(âs2member_custom_fieldsâ, $user_id);
$street = $current_user->street;
Thanks all, I just managed it!!!
in my functions.php I added following instruction:
add_filter( âgform_field_value_straatnaamâ, âpopulate_straatnaamâ );
function populate_straatnaam( $value ) {
$my_straatnaam = get_user_field(âstraatnaamâ); # The Unique Field ID you configured with s2Member.
return $my_straatnaam;
}