Settings Mail values via JS

SupportSettings Mail values via JS
Chandra asked 6 years ago
Hi Nikola, I am trying to set some mail content via jQuery. Interestingly, some work like ea_settings['submit.redirect'] = ''; // or give any value but when I try  ea_settings['mail.pending'] = 'so and so'; It doesn't work. I do see an array when I view source and some settings are affected by JS and some aren't like this. Is there a way we can do this? I also check the filters but not sure how we can set it via filters depending upon what particular field is input.   Any guidance would be awesome.   Thanks,
Chandra
maharzan Staff replied 6 years ago

I see these on the source, if overwriting it doesn’t work, I am wondering what is it used for…

var ea_settings = {“mail.pending”:”pending”,”mail.canceled”:”canceled”,”mail.confirmed”:”confirmed”,”mail.admin”:””….

It would be great to overwrite this or have add_filter overwrite it with some logic. I am using different conditions in the form and sending a slightly different email depending on that form input.

Thanks,
Chandra

Nikola Loncar Staff replied 6 years ago

Hi Chandra, there is already filter for mail content.

Best regards,
Nikola

maharzan Staff replied 6 years ago

I saw that Nikola, I wanted to grab a field setting from ea_fields table and depending on that, I want to change the content of email. I am not sure how to do that.. something like doing get_post(id) for ea_fields. How are you doing that in the plugin?

1 Answers
maharzan Staff answered 6 years ago
I found this function get_fields_for_apps($id) that might do what I am looking for but how do I access this function? Trying  $cla = new EADBModels();
$getdata = $cla->get_fields_for_apps(136); gets me missing arguments errors. 
maharzan Staff replied 6 years ago

I think I found a solution. I directly ran the SQL query..

$wpdb->get_results( “SELECT value FROM wp_ea_fields where app_id=”. $app->id .” AND field_id=22″ );

If there is a better solution, I would be very happy to know.

Thanks,
Chandra

Nikola Loncar Staff replied 6 years ago

Check constructor new EADBModels(); , you are missing params there. You can also access that via plugin global object.

Best regards,
Nikola