Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- /**
- * Set the email and name from the logged-in user
- * @param array $fields
- * @return array
- */
- add_filter('site-reviews/review-form/fields/normalized', function ($fields) {
- if (!is_user_logged_in()) {
- return $fields;
- }
- $user = wp_get_current_user();
- array_walk($fields, function ($field) use ($user) {
- if ('email' === $field->path) {
- $field->value = $user->user_email;
- }
- if ('name' === $field->path) {
- $field->value = $user->display_name;
- }
- });
- return $fields;
- });
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement