Skip to content

Commit

Permalink
Fix missing data in email submissions
Browse files Browse the repository at this point in the history
  • Loading branch information
aristath committed Jan 2, 2024
1 parent 2d43054 commit 5caf443
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 5caf443

Please sign in to comment.