Skip to content

Instantly share code, notes, and snippets.

@codearachnid
Created January 26, 2015 00:04
Show Gist options
  • Select an option

  • Save codearachnid/a0850349f02ce9804301 to your computer and use it in GitHub Desktop.

Select an option

Save codearachnid/a0850349f02ce9804301 to your computer and use it in GitHub Desktop.
Populate a gravity forms field for a currently logged in user
<?php
add_filter( 'gform_field_value_user_name', 'my_custom_gform_field_user_name' );
function my_custom_gform_field_user_name( $value ){
$current_user = wp_get_current_user();
if ( 0 != $current_user->ID ) {
$value = $current_user->display_name;
}
return $value;
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment