Skip to content

Commit 70cc917

Browse files
author
Antti Kuosmanen
committed
Make email example more readable
1 parent 1dea70f commit 70cc917

1 file changed

Lines changed: 9 additions & 3 deletions

File tree

README.md

Lines changed: 9 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -137,12 +137,18 @@ These actions are only run for the target form by ID or slug.
137137
```php
138138
add_action( 'wplf_post_validate_submission', 'my_email_thankyou' );
139139
function my_email_thankyou( $return ) {
140+
// recipient details from submission
140141
$name = sanitize_text_field( $_POST['name'] );
141142
$email = sanitize_email( $_POST['email'] );
142-
$to = "\"$name\" <$email>";
143+
144+
// email subject
143145
$subject = __( 'Thank You For Submitting A Form' );
144-
$content = wp_sprintf( __('Thanks, %s for clicking Submit on this glorious HTML5 Form!'), $name );
145-
wp_mail( $to, $subject, $content );
146+
147+
// text body of email
148+
$body = wp_sprintf( __('Thanks, %s for clicking Submit on this glorious HTML5 Form!'), $name );
149+
150+
// send the email
151+
wp_mail( $email, $subject, $body );
146152
}
147153
```
148154

0 commit comments

Comments
 (0)