I am using gravity hooks to set some input automatically. my code is:
$current_user = wp_get_current_user();
add_filter( ‘gform_field_value_stuname’,‘get_firstname’,999, 1 );
It’s work fine and the “name” field filled automatically.
The problem is that when I submit the form the “name” field will save empty!!
I didn’t find any way to solve this.
Can anyone help me?
For a logged in user, you do not need any code. You can use these user merge tags as “default value” for a field in the form:
This will work to get the first name of the logged in user who submits the form:
Yes, it’s working but I fetch more data from the database and show it in gravity. I use cimy user extra fields plugin to make some extra field in the registration form and I want to show it in gravity form. so the cimy plugin table is different from other plugins. for example, I wrote this code:
$uid = get_current_user_id();
global $wpdb, $stdpunm;
$stdpunm = $wpdb->get_results("SELECT * FROM wp_cimy_uef_data WHERE USER_ID = $uid" );
So i have to use hooks in my forms. any solution?