-
Notifications
You must be signed in to change notification settings - Fork 4.2k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Fix missing data in email submissions #55691
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -96,7 +96,7 @@ function block_core_form_send_email() { | |
'<a href="' . esc_url( get_site_url( null, $params['_wp_http_referer'] ) ) . '">' . get_bloginfo( 'name' ) . '</a>' | ||
); | ||
|
||
$skip_fields = array( 'formAction', '_ajax_nonce', 'action' ); | ||
$skip_fields = array( 'formAction', '_ajax_nonce', 'action', '_wp_http_referer' ); | ||
foreach ( $params as $key => $value ) { | ||
if ( in_array( $key, $skip_fields, true ) ) { | ||
continue; | ||
|
@@ -109,7 +109,7 @@ function block_core_form_send_email() { | |
|
||
// Send the email. | ||
$result = wp_mail( | ||
str_replace( 'mailto:', '', $params['wp-email-address'] ), | ||
str_replace( 'mailto:', '', $params['formAction'] ), | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. This seems like the main bug fixed here, right? There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Correct |
||
__( 'Form submission', 'gutenberg' ), | ||
$content | ||
); | ||
|
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -20,6 +20,8 @@ document.querySelectorAll( 'form.wp-block-form' ).forEach( function ( form ) { | |
formData.formAction = form.action; | ||
formData._ajax_nonce = wpBlockFormSettings.nonce; | ||
formData.action = wpBlockFormSettings.action; | ||
formData._wp_http_referer = window.location.href; | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Overriding There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. The data is not actually sent with the AJAX request... so we're just adding it here. |
||
formData.formAction = form.action; | ||
|
||
try { | ||
const response = await fetch( wpBlockFormSettings.ajaxUrl, { | ||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Maybe too late but it'd be great if we could instead of keeping alist of fields to skip, find a way to identify what to include - like if we had a prefix for all fields that should be emailed or something?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Well, the args that need to be ignored are finite and known... That's why I thought it best to keep it clean and not add prefixes to the other ones. 😃
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Today! But one day some hidden thing _don't_email_me will show up and be emailed :)