How to Customize your Available Spaces Text
In some cases, you may not always want to display the number of available spaces, but you do want to let people know that spaces are, in fact, available. In certain situations, there may be the perception that if there are a lot of available spaces, that an event may close, which would dissuade people from signing up even if that isn’t the case. This simple tweak will allow you to inform your users that there are spaces available without disclosing exactly how many until there are only a few left.
You will be modifying PHP code. You will need a text editor or an IDE. Always make a backup and, if possible, test on a local or development install rather than making changes to your live site. Template files should always be uploaded to /wp-content/uploads/espresso/templates/
and not the plugin templates directory. While we have provided this tutorial and may be able to provide some amount of support for it, we cannot support any customizations you make to your own site.
Note: This will be updated for Event Espresso 3.2.
There are two files that we will be looking at. event_list_display.php and registration_page_display.php.
In your favorite text editor or IDE, open event_list_display.php and scroll down to lines 94-106. This deals with the Available Spaces message that appears in the event list. We are going to change the text from “Available Spaces: ” and a number, to something more friendly that does not reveal the number of spaces available. Jump down to line 103 and replace this:
<?php if ($display_reg_form == 'Y' && $externalURL == '') {?> <p id="available_spaces-<?php echo $event_id ?>" class="spaces-available"></p> <p id="available_spaces-<?php echo $event_id ?>" class="spaces-available"></p> <?php } ?>
with this:
<?php if ($display_reg_form == 'Y' && $externalURL == '') { ?> <p id="available_spaces-<?php echo $event_id ?>" class="spaces-available"><span class="section-title"> <?php if ( get_number_of_attendees_reg_limit($event_id, 'available_spaces') >= '10' ) { echo 'Sign up now! Spaces are available!'; } else { echo 'Time\'s running out! Only ' . get_number_of_attendees_reg_limit($event_id, 'available_spaces') . ' spaces left!'; } ?></span></p> <?php } ?>
This will display this message if there are 10 or more spaces available:
Sign up now! Spaces are available!
and this message if there are less than 10:
Time’s running out! Only xx spaces left!
While we’re at it, let’s change the default waiting list and no spaces available messages a little friendlier. Pop up to line 97. This area deals with what happens if there are no available spaces left. First, on line 97, we’re going to replace this:
<p id="available_spaces-<?php echo $event_id ?>"><span><?php _e('Available Spaces:', 'event_espresso') ?> </span><?php echo get_number_of_attendees_reg_limit($event_id, 'available_spaces', 'All Seats Reserved') ?></p>
with this:
<p id="available_spaces-<?php echo $event_id ?>"><?php echo get_number_of_attendees_reg_limit($event_id, 'available_spaces', 'There are no more spaces available for this event.') ?></p>
If you have waiting lists set up, you might want to change the text that displays for that (line 99). Replace this:
<p id="register_link-<?php echo $overflow_event_id ?>"><a id="a_register_link-<?php echo $overflow_event_id ?>" href="<?php echo espresso_reg_url($overflow_event_id); ?>" title="<?php echo stripslashes_deep($event_name) ?>"><?php _e('Join Waiting List', 'event_espresso'); ?></a></p>
with this:
<p id="register_link-<?php echo $overflow_event_id ?>"><a id="a_register_link-<?php echo $overflow_event_id ?>" href="<?php echo espresso_reg_url($overflow_event_id); ?>" title="<?php echo stripslashes_deep($event_name) ?>"><?php _e('Sign up on the waiting list?', 'event_espresso'); ?></a></p>
So, the whole thing will look like this:
<?php $num_attendees = get_number_of_attendees_reg_limit($event_id, 'num_attendees'); //Get the number of attendees. Please visit https://eventespresso.com/forums/?p=247 for available parameters for the get_number_of_attendees_reg_limit() function. if ($num_attendees >= $reg_limit) { ?> <p id="available_spaces-<?php echo $event_id ?>"></p> <p id="register_link-<?php echo $overflow_event_id ?>" class="register-link-footer"></p> <p id="available_spaces-<?php echo $event_id ?>" class="spaces-available"></p> <p id="available_spaces-<?php echo $event_id ?>"></p> <p id="register_link-<?php echo $overflow_event_id ?>" class="register-link-footer"></p> <p id="available_spaces-<?php echo $event_id ?>" class="spaces-available"></p> <?php } } ?>
Feel free to let us know in the forums if you have any questions about this tutorial!