Title: Auto-populate Fields
Last modified: March 4, 2018

---

# Auto-populate Fields

 *  Resolved [fuji9](https://wordpress.org/support/users/fuji9/)
 * (@fuji9)
 * [8 years, 3 months ago](https://wordpress.org/support/topic/auto-populate-fields-3/)
 * Is there a way to auto-populate fields in the testimonial form with data from
   logged in user? for example, email, first name, last name, etc.

Viewing 1 replies (of 1 total)

 *  anonymized-13171256
 * (@anonymized-13171256)
 * [8 years, 3 months ago](https://wordpress.org/support/topic/auto-populate-fields-3/#post-10037552)
 * Here’s a generic example. Add this to your theme’s functions.php or create an
   mu-plugin.
 *     ```
       /**
        * Insert name and email of currently logged-in user into testimonial submission form.
        * For Strong Testimonials plugin.
        *
        * @param $value
        * @param $field
        * @param $form_values
        *
        * @return mixed
        */
       function my_strong_field_value( $value, $field, $form_values ) {
       	// Don't overwrite existing entry. Only possible if a default value is set
       	// on the form field or JavaScript and HTML validation is disabled.
       	if ( ! $value ) {
   
       		// Get current user
       		$current_user = wp_get_current_user();
   
       		// 'client_name' and 'email' are the default field names.
       		// Change these if yours are different.
       		if ( 'client_name' == $field['name'] ) {
       			$value = $current_user->data->display_name;
       		} elseif( 'email' == $field['name'] ) {
       			$value = $current_user->data->user_email;
       		}
   
       	}
   
       	return $value;
       }
       add_filter( 'wpmtst_field_value', 'my_strong_field_value', 10, 3 );
       ```
   

Viewing 1 replies (of 1 total)

The topic ‘Auto-populate Fields’ is closed to new replies.

 * ![](https://ps.w.org/strong-testimonials/assets/icon-256x256.png?rev=3134855)
 * [Strong Testimonials](https://wordpress.org/plugins/strong-testimonials/)
 * [Frequently Asked Questions](https://wordpress.org/plugins/strong-testimonials/#faq)
 * [Support Threads](https://wordpress.org/support/plugin/strong-testimonials/)
 * [Active Topics](https://wordpress.org/support/plugin/strong-testimonials/active/)
 * [Unresolved Topics](https://wordpress.org/support/plugin/strong-testimonials/unresolved/)
 * [Reviews](https://wordpress.org/support/plugin/strong-testimonials/reviews/)

 * 1 reply
 * 2 participants
 * Last reply from: anonymized-13171256
 * Last activity: [8 years, 3 months ago](https://wordpress.org/support/topic/auto-populate-fields-3/#post-10037552)
 * Status: resolved