Skip to content

Instantly share code, notes, and snippets.

@kevinwhoffman
Created April 14, 2017 18:53
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save kevinwhoffman/47810c2c0f2dbd3d44e137033f5d7504 to your computer and use it in GitHub Desktop.
Save kevinwhoffman/47810c2c0f2dbd3d44e137033f5d7504 to your computer and use it in GitHub Desktop.
Pre-populate Caldera Forms field based on slug
<?php
/**
* Pre-populate First Name field if user is logged in.
*/
function filter_caldera_forms_render_get_field_first_name( $field, $form ) {
$current_user = wp_get_current_user();
if ( is_user_logged_in() ) {
$field['config']['default'] = $current_user->user_firstname;
}
return $field;
};
add_filter( 'caldera_forms_render_get_field_slug-first_name', 'filter_caldera_forms_render_get_field_first_name', 10, 2 );
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment