_BOOKINGFORMCUSTOM field not found
-
What can expect the _BOOKINGFORMCUSTOM(field_id) to return if the field_id does not exist in the. It is not null nor empty sting.
Thanks
-
This topic was modified 7 years, 1 month ago by
adirdal.
-
This topic was modified 7 years, 1 month ago by
-
Check your spelling, please 😉
#_BOOKINGFORMCUSTOM{field_id} and field_id is of course what you put in the booking form editor 😉-
This reply was modified 7 years, 1 month ago by
Stonehenge Creations.
Sorry, my bad. I did not check my spelling when posting this topic, but I don’t think my code has the same spelling error:
My code looks like this:
$EM_Booking->output(‘#_BOOKINGFORMCUSTOM{nickname}’);
It works if the field exists. But when the field does not exist it returns something like this:
<div id=”em-booking” class=”em-booking css-booking”>
<p>Booking is closed.</p>
</div>CUSTOM{nickname}-
This reply was modified 7 years, 1 month ago by
adirdal.
That’s strange… If I use that and the field id does not exists, it simply echoes
#_BOOKINGFORMCUSTOM{field_id} (literally), not the div…Where are you using this?
attendeelist placeholder:
<?php /* @var $EM_Event EM_Event */ $people = array(); $EM_Bookings = $EM_Event->get_bookings(); if( count($EM_Bookings->bookings) > 0 ){ ?> <ul class="event-attendees"> <?php foreach( $EM_Bookings as $EM_Booking){ /* @var $EM_Booking EM_Booking */ $nickname = $EM_Booking->output('#_BOOKINGFORMCUSTOM{nickname}'); if($EM_Booking->booking_status == 1 && !in_array($EM_Booking->get_person()->ID, $people) ){ $people[] = $EM_Booking->get_person()->ID; if($nickname != ''){ echo '<li>'. $nickname .'</li>'; }else{ echo '<li>'. $EM_Booking->get_person()->get_name() .'</li>'; } }elseif($EM_Booking->booking_status == 1 && $EM_Booking->is_no_user() ){ if($nickname != ''){ echo '<li>'. $nickname .'</li>'; }else{ echo '<li>'. $EM_Booking->get_person()->get_name() .'</li>'; } } } ?> </ul> <?php }Please revise your message.
You need to wrap your code in ticks (use the buttons at the top the input field). You are now breaking the forum and I cannot read the code clearly.Yes, I noticed. Fixed now.
Why the check !in_array() for $people? It appears to always be empty as you’ve just declared it…
Try this:
if( @$nickname && !empty($nickname)) { echo '<li>'. $nickname .'</li>'; }else{The !in_array() for $people? is the original code.
Thanks. I will test.
Let me rewrite that for you…
I do not understand the overkill in if/else. You are always outputting the same thing: either the nickname or the full name. Right?So the only actual check is if the User ID needs to be added to $people.
<?php $people = array(); $EM_Bookings = $EM_Event->get_bookings(); if( count($EM_Bookings->bookings) > 0 ) { echo '<ul class="event-attendees">'; foreach( $EM_Bookings as $EM_Booking) { $nickname = @$EM_Booking->output('#_BOOKINGFORMCUSTOM{nickname}') ? $EM_Booking->output('#_BOOKINGFORMCUSTOM{nickname}') : $EM_Booking->get_person()->get_name(); if($EM_Booking->booking_status === 1) { // Only target approved bookings (Status 1). if( !in_array($EM_Booking->get_person()->ID, $people) ) { // Add User ID to array if not yet in it. $people[] = $EM_Booking->get_person()->ID; } echo "<li>{$nickname}</li>"; } } // end foreach() echo '</ul>'; } ?>I agree.
Just testet your suggestion, but it did not work. I now printed out the content of the $nickname field with this:
$nickname = $EM_Booking->output('#_BOOKINGFORMCUSTOM{nickname}'); echo '</li><div style="display:none;">'. $nickname .'</div>';But what is printed is:
<div style="display:none;"><div id="em-booking" class="em-booking css-booking"> <form class="em-booking-form" name="booking-form" method="post" action="#em-booking"> <input type="hidden" name="action" value="booking_add"> <input type="hidden" name="event_id" value="1200"> <input type="hidden" name="_wpnonce" value="940c98b201"> <p class="em-booking-form-details">Du må logge inn eller registrere deg for å gjøre en bestilling.</p> </form> <br class="clear" style="clear:left;"> </div>CUSTOM{nickname}</div>-
This reply was modified 7 years, 1 month ago by
adirdal.
For reading purposes: 😉
$booking_field = $EM_Booking->output("#_BOOKINGFORMCUSTOM{nickname}"); $nickname = @$booking_field && !empty($booking_field) ? $booking_field : $EM_Booking->get_person()->get_name();Okay, what seems to happen is that the output is broken up. #_BOOKINGFORM echos the (guess what??) Bookingform. That is the div style bla bla you get. Because after your “booking form” the output continues with “CUSTOM{nickname}”, which is actually the last part of the original placeholder.
What if you replace ‘ with ” ?
$EM_Booking->output("#_BOOKINGFORMCUSTOM{nickname}");Thanks!
I think that worked. Replacing ‘ with “.
I will test on my real code and let you know.No. It did not work. Still printing the <DIV…
I hear a Twighlight Zone (the series) music coming on…
Let’s go in hard… Just to rule out anything else.
Add this to your functions.php:function test_placeholder($replacement, $EM_Booking, $result) { if($result === '#_NICKNAME') { $replacement = $EM_Booking->output("#_BOOKINGFORMCUSTOM{nickname}"); } return $replacement; } add_filter('em_booking_output_placeholder', 'test_placeholder', 1, 3);Then in your Attendee List code, replace $EM_Booking->output(“#_BOOKINGFORMCUSTOM{nickname}”) with
$EM_Booking->output(“#_NICKNAME”)Where do I find functions.php? Do you mean em-functions.php?
-
This reply was modified 7 years, 1 month ago by
The topic ‘_BOOKINGFORMCUSTOM field not found’ is closed to new replies.