I am creating a plugin using WordPress plugin boilerplate (/), I have create a separate file for sending emails under /admin/partials/ directory. but wordpress throw error when I am using wp_mail function in this file. any solution for this?
Fatal error: Uncaught Error: Call to undefined function wp_mail()
I am creating a plugin using WordPress plugin boilerplate (https://wppb.me/), I have create a separate file for sending emails under /admin/partials/ directory. but wordpress throw error when I am using wp_mail function in this file. any solution for this?
Share Improve this question asked Jan 26, 2020 at 16:30 Sahil BuddhadevSahil Buddhadev 11 bronze badgeFatal error: Uncaught Error: Call to undefined function wp_mail()
1 Answer
Reset to default 0If it's undefined, that means you're trying to run wp_mail()
before it is loaded. Whatever you've hooked it to is too early. Hook your process to a later action. Essentially, anything like plugins_loaded
or later.