That’s because you have put function tps_set_html_email_content_type inside the tps_send_email, and each time you call it, it will declare the tps_set_html_email_content_type function again. Just move it out:
function tps_set_html_email_content_type() {
return 'text/html';
}
function tps_send_email($emailTo, $subject, $content) {
add_filter( 'wp_mail_content_type', 'tps_set_html_email_content_type' );
//Send the email
$mailSent = wp_mail($emailTo, $subject, $content);
//Reset HTML content type back to text only (avoids conflicts)
remove_filter( 'wp_mail_content_type', 'tps_set_html_email_content_type' );
return $mailSent;
}
I am not sure why you would put one function inside another one in the first place, but that is never a good idea, even so PHP supports it.
Related Posts:
- How to add headers to outgoing email?
- wp_mail – Remove sitename from email subject
- Help with filter for wp_notify_moderator()
- Filter wp_mail based on content type
- Editing ‘Password Reset’ E-mail
- How to apply the “retrieve_password_message” filter?
- How to disable all WordPress emails modularly and programatically?
- How to override the email function by using filters? [closed]
- wpmu_signup_user_notification filter not working
- Change email from and display name with a filter action
- wp_mail works with add_action(‘save_post’, …) but not an ajax action
- Is it possible to put the add-filter()-hook into a function?
- How can I change the email that is inside the default email texts of wordpress?
- Which Filter Do I Use To Modify The Subject Of The Retrieve Password Notification Email?
- Email Obfuscation: Is antispambot() Acceptable? [closed]
- arguments for comment_notification_text filter
- Would like to use hook or filters to customize email templates
- How to filter users on admin users page by custom meta field?
- Custom theme hooks / filters – passing arguments
- Fatal error: Call to undefined function wp_mail()
- Mail will not send in HTML
- What params are available with the_content filter?
- How to hook wp_list_pages?
- Don’t replace “|” with Empty String (“”) when generating slugs from title
- apply_filters(‘the_content’, $content) alternative
- How to exclude/filter a tag from get_the_tag_list()
- Changing document title only on a custom page template
- Filter the blog’s title without using global variables
- user_has_cap filter allows edit but will not allow save
- Add filter to wp_dropdown_pages() or wp_dropdown_categories() – no select container?
- Hook different functions to the same filter conditionally OR Pass additional arguments to existing filter?
- How do I pass the value from a foreach loop to an add_filter function? [closed]
- How to create a CSV on the fly and send as an attachment using wp_mail?
- Must I change the admin user email address while changing the general email address?
- Search results sorted by post types
- where to apply “apply filters” and other Sanitization Functions
- Add guid filter to attachment in media library grid mode
- Pass parameter to the upload_dir filter
- Filter or Hook to catch pre-rendering of post content
- check to see if hook is available
- Filter users by custom colum not meta key
- How to allow users to view pending posts of a specific custom post type?
- Remove filter callback: method in class
- add_filter(‘the_content’, ‘…’) stops pagination from working
- How can I exclude tags from category_rss function?
- How do I use remove_action on an add_action that uses an array?
- Change the default 10-day expiration for the password protected pages cookie
- Add content as soon starts
- Access get_the_title() from ‘excerpt_length’ filter
- How can I change the language of automated Mails?
- wp_mail() not sending email in multisite subdomain
- Google Apps SMTP for WP MultiSite?
- How can I replace an oEmbed URL in post with actual embed HTML
- Replacing a deprecated filter ‘woocommerce_get_price’ with ‘woocommerce_product_get_price’
- How do you get specific tags from the_content?
- Add a filter inside an action init
- Is it possible to apply_filter on a wp_ajax_ action?
- Apply filters with multiple filters
- Using add_filter to prepend content, result is out of order
- Remove Comment Author Link only for subscribers
- WordPress: Add custom add_filter for custom functions
- get_posts() interrupt because of filter
- Rewrite rule and display of post
- add_filter the_content doesn’t work
- Redirect to woocommerce checkout after adding to cart – item already in cart
- Passing variable from child theme function to parent theme filter
- `authenticate` filter never gets called
- paginate_links() Change the order of links
- How to disable a wp filter in a certain admin panel page
- Is there a filter to programmatically change the HTML tab switching output of the page editor?
- Why does admin_body_class not work?
- post_orderby filter breaks function
- Disable Remember Me in Login Form
- How do I add a line break to a string that is output by PHP?
- Counting a WP_Post Object value in an arary, using a filter?
- Updated : how to make email optional while user registration using default wordpress form
- List all categories that have results in a query
- Distinguish between page and post in function
- Display posts from today and future in Elementor ‘posts widget’
- Right filter for rewriting page statuscode
- How to filter page title for certain page?
- Displaying posts on a page that have been assigned a value in a database
- Replace Text with hyperlinks
- adding an action inside if condition not working
- Adding filter to an specific page/site direction
- How to filter wp_get_recent_posts() to only posts that have thumbnails?
- How to check which submission button was clicked?
- check, if any “add_action” function contains string XXXXXXXXX
- remove_action conditionally for Custom Post Type – not working
- wp_get_attachment_link filter not working
- How would I remove an inline googleAPI font script in the the parent theme header.php?
- Joining tables not working in the post editor page
- Auto append text after the title?
- Is there a hook or filter that adds a button to the left of the search box?
- Filter and manipulate the get_current_user() function
- add_filter(‘the_content’, ‘method’) does not trigger my custom method
- Better way to change the default password reset url with the woocommerce one?
- woocommerce_coupon_is_valid_for_product not working to exclude specific product tag
- Change password reqts with NO plugin without breaking resetpass link?
- How can I conditionally add the filter option_home?