Created
April 14, 2017 18:53
-
-
Save kevinwhoffman/47810c2c0f2dbd3d44e137033f5d7504 to your computer and use it in GitHub Desktop.
Pre-populate Caldera Forms field based on slug
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?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