anonymized-13171256
(@anonymized-13171256)
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 );