@june01
You can try this code snippet to remove all empty registration fields in the email message:
add_filter( 'wp_mail', 'custom_email_um_remove_empty', 10, 1 );
function custom_email_um_remove_empty( $args ) {
$message_lines = explode( '<p>', $args['message'] );
$new_message = array();
foreach( $message_lines as $message_line ) {
if( !strpos( $message_line, '<span>(empty)</span>')) $new_message[] = $message_line;
}
$args['message'] = implode( '<p>', $new_message );
return $args;
}
Install the code snippet into your active theme’s functions.php file
or use the “Code Snippets” plugin.
https://wordpress.org/plugins/code-snippets/
-
This reply was modified 3 years, 4 months ago by
missveronica.
Thread Starter
june01
(@june01)
Do I just need to add the code snippet ? Or do I need to change anything else?
I copied the exact same snippet, but it didn’t work. Nothing happened. I still got an email with empty fields.
@june01
Are you using a SMTP Plugin?
Do you have a local language setting?
-
This reply was modified 3 years, 4 months ago by
missveronica.
@june01
Updated the code snippet not to be dependent on English language only:
add_filter( 'wp_mail', 'custom_email_um_remove_empty', 10, 1 );
function custom_email_um_remove_empty( $args ) {
$message_lines = explode( '<p>', $args['message'] );
$new_message = array();
foreach( $message_lines as $message_line ) {
if( !strpos( $message_line, '<span>' . __( '(empty)', 'ultimate-member' ) . '</span>')) $new_message[] = $message_line;
}
$args['message'] = implode( '<p>', $new_message );
return $args;
}
Thread Starter
june01
(@june01)
yes I am using WP Mail SMTP by WPForms and my website is in Arabic.
@june01
With the last update your language will be supported.
Let’s see if your SMTP Plugin is creating the issue.
Thread Starter
june01
(@june01)
the last code works, all empty fields are gone now. Thank you very much.