Wordpress functions do not work via ajax

Asked

Viewed 116 times

0

I am creating a plugin for Wordpress with an audio recorder. By clicking a button I need to call a function from within my plugin to send an email with that audio.

I didn’t understand how to use the do_action(), in this case then I am trying via AJAX, however when I make the request via POST in the main PHP file of my plugin the Wordpress functions are not working as the wp_mail() I’m using to send the email.

Does anyone know if this is the normal behavior of Wordpress? How can I implement this email sending?

  • You’re making a $_POST for the main file of your plugin and no WP function works or is only the wp_mail()?

  • in fact Caio was my Ajax that was not right, to work with ajax in WP it is necessary to use the prefix 'wp_ajax' and I was not using so it was not working the functions of WP. But now I’m having trouble picking up my audio file and attaching it in the email. i have on my page a '<audio src="my.mp3">' but I don’t know how to attach this guy in the email I’m sending, because when I pick up the file with the '$_Files[]' it comes empty and doesn’t send the email

  • Carlos, did you try to use the image path? something like $anexo = WP_CONTENT_DIR . '/uploads/arquivo.zip' ?

No answers

Browser other questions tagged

You are not signed in. Login or sign up in order to post.