You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
You can use the wp_mail_from_name filter in WordPress to dynamically set the "From Name" based on the form submission data. Below is a workaround function that checks if the email is being sent by Ninja Forms and sets the "From Name" to the name of the form submitter.
157
+
Explanation:
158
+
The function hooks into the wp_mail_from_name filter.
159
+
It checks if the email is being sent by Ninja Forms by inspecting the $phpmailer global object.
160
+
If the email is from Ninja Forms, it retrieves the submitter's name from the email headers or content.
161
+
It sets the "From Name" dynamically.
162
+
163
+
164
+
```php
165
+
add_filter('wp_mail_from_name', function ($from_name) {
166
+
global $phpmailer;
167
+
168
+
// Check if PHPMailer is initialized
169
+
if (!isset($phpmailer) || !is_object($phpmailer)) {
170
+
return $from_name;
171
+
}
172
+
173
+
// Check if the email is from Ninja Forms
174
+
if (isset($phpmailer->Subject) && strpos($phpmailer->Subject, 'Ninja Forms') !== false) {
175
+
// Extract the submitter's name from the email headers or body
176
+
if (preg_match('/Name:\s*(.+)/i', $phpmailer->Body, $matches)) {
177
+
$from_name = trim($matches[1]);
178
+
}
179
+
}
180
+
181
+
return $from_name;
182
+
});
183
+
```
184
+
154
185
## Screenshots
155
186
156
187
1. The initial setup wizard will guide you through the quick steps to get started
echo__('Add a subscription form to your website', 'mailjet-for-wordpress');
@@ -68,18 +56,10 @@ public function mailjet_allsetup_page_html() {
68
56
_e('Go to the widget management page and add the Mailjet Subscription Widget to your website to start collecting email addresses.', 'mailjet-for-wordpress');
echo__('Send an email campaign', 'mailjet-for-wordpress');
@@ -90,18 +70,10 @@ public function mailjet_allsetup_page_html() {
90
70
_e('Ready to send a newsletter to your subscribers? Simply go to your Campaigns and click on "Create a campaign" to create and send your email.', 'mailjet-for-wordpress');
0 commit comments