Events Made Easy Forums How do I … eme_get_answers problem

Viewing 9 posts - 1 through 9 (of 9 total)
  • Author
    Posts
  • #58398
    Anonymous
    Inactive

    Note, I am using #_ADDBOOKINGFORM to create the booking form on the event.
    I have been busting my butt on making this fly for me and every time I try and run
    $answers = eme_get_answers($booking[‘booking_id’]); the script breaks. I just need to get that variable whether they want the newsletter. Below is just the beginning of the code. What in the eme_get_answers function will not work for me? I am calling the eme_get_person with the person_id just fine. Thanks for any help. Every example you have shows to do it this way!

    function my_eme_custom_stuff($booking) {
        global $wpdb;
        $bookings_table = $wpdb->prefix.BOOKINGS_TBNAME;
        $answers = eme_get_answers($booking['booking_id']);
    	//print_r($booking);
    	foreach ($answers as $answer) {
                if ($answer['FIELD1'] == "Yes") {
                   $news = "Yes";
                }
            }
    #58403
    Franky
    Keymaster

    First: I’ve split out your topic, please read the forum posting rules!
    Second: the documentation was wrong. Well, it was correct in the past, but since I added members and more stuff, eme_get_answers was not sufficient anymore, so I renamed it to eme_get_booking_answers.
    I corrected the doc (the function was already renamed in 2017, apparently nobody noticed it …).

    #58404
    Anonymous
    Inactive

    Thanks Franky. I read so many like posts I didn’t want to spit out a new one. My bad. Donation on the way!

    #58405
    Franky
    Keymaster

    No problem.
    Btw: EME is more than capable of handling it’s own mailings, it has a good mailing system with follow-up as well, no need for mailchimp 🙂

    #58406
    Anonymous
    Inactive

    Client wants them in MailChimp not for event contact info but newsletter sends.
    Note: now that I am pulling the correct function I am still not getting the return of yes on that answer. I have named the form field ‘mailchimp’, made it generic and embedded in my form. Checkboxes. Am I calling that correct below?

    $answers = eme_get_booking_answers($booking_id);
    foreach ($answers as $answer) {
    if ($answer[‘mailchimp’] == “Yes”) {
    $news = “Yes”;
    }
    }

    #58407
    Franky
    Keymaster

    EME can send out newsletters too … planned in time and all.
    But no, that is not correct. See the (now correct) examples on the site. E.g.:

    
    foreach ($answers as $answer) {
       if ($answer['field_name'] == "mailchimp") {
          $mailchimp_choice = $answer['answer'];
       }
    }
    

    That will get the answer in $mailchimp_choice, so now you can do a print_r on $mailchimp_choice (or $answer) and go from there 🙂
    This is also a good example, if you ever need to take it further:

    
             foreach ($answers as $answer) {
                $tmp_formfield = eme_get_formfield($answer['field_id']);
                $tmp_answer=eme_convert_answer2tag($answer['answer'],$tmp_formfield);
                print $answer['field_name'].": $tmp_answer\n";
             }
    
    #58514
    Anonymous
    Inactive

    The script we worked on above is no longer working. It never picks up the “Yes” on the answer and there for doesn’t trigger my MailChimp API down the road. Whenever I try and print_r out it tells me there was an error on submission. It is almost like the booking_id isn’t coming in to help me get the answers. We changed domains since we started. Could that throw some issues? This one has me confused!

    global $wpdb;
    $bookings_table = $wpdb->prefix.BOOKINGS_TBNAME
    $booking_id = $booking[‘booking_id’];
    $answers = eme_get_booking_answers($booking_id);
    foreach ($answers as $answer) {
    if ($answer[‘field_name’] == “mailchimp”) {
    $news = $answer[‘answer’]; <– This isn’t returning a yes answer that it used to
    }
    }

    #58515
    Franky
    Keymaster

    Exactly where are you calling that script? In what filter/hook? You never specified this …
    And: if you use a print_r, it will indeed say your submission failed (but do it) because WP ajax calls expect a specific return format (json encoded), and your print_r breaks that. But using your browser debugger you can see what has been returned in the network tab after you press submit (your print_r output will be there).
    Now, if you call this function in the hook eme_insert_rsvp_action, it should work as expected (try your print_r then).

    #58576
    Anonymous
    Inactive

    Sorry for the delay. Looks like my original comment didn’t go through.
    ’eme_insert_rsvp_action’ is the hook. I will look at the output and let you know.

Viewing 9 posts - 1 through 9 (of 9 total)
  • The forum ‘How do I …’ is closed to new topics and replies.
Scroll to Top