Skip to content

Commit

Permalink
Fix missing data in email submissions (#55691)
Browse files Browse the repository at this point in the history
  • Loading branch information
aristath authored Jan 30, 2024
1 parent 161b2e4 commit 3eb68c2
Show file tree
Hide file tree
Showing 2 changed files with 4 additions and 2 deletions.
4 changes: 2 additions & 2 deletions packages/block-library/src/form/index.php
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand All @@ -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'] ),
__( 'Form submission', 'gutenberg' ),
$content
);
Expand Down
2 changes: 2 additions & 0 deletions packages/block-library/src/form/view.js
Original file line number Diff line number Diff line change
Expand Up @@ -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;
formData.formAction = form.action;

try {
const response = await fetch( wpBlockFormSettings.ajaxUrl, {
Expand Down

0 comments on commit 3eb68c2

Please sign in to comment.