Support

Home Forums Event Espresso Premium Changing an event registration alert to hide the date for a specific event

Changing an event registration alert to hide the date for a specific event

Posted: August 4, 2014 at 12:04 pm

Viewing 7 reply threads


James Simon

August 4, 2014 at 12:04 pm

What is the name of the file that generates the information on the event registration page? I have been searching through php files, looking for code that is tied to the event_espresso_form_wrapper class. I would like to change the alert for a specific event without changing the alerts for the other events. I am attempting to hide the date that is included in the alert. I already tried removing the date from the event itself, but now the alert says “You have registered for event name on .” I would like to change it to “You have registered for event name.” while keeping the original for all other events.


Dean

August 5, 2014 at 2:25 am

Hi James,

Which version of EE are you referring to?

Which alert (or perhaps message?) are you referring to as I cannot trace that text in either plugin?

I’d be happy to help you resolve this, I just need to clarify exactly what it is you are trying to change.

Thanks.


James Simon

August 5, 2014 at 2:45 pm

Hi Dean,

We are using EE 3.1.35.2.

A colleague showed me the file that has a hard coded message in it. The file is registration_page_display.php located in \wp-content\plugins\event-espresso\templates.

What I am now trying to do is create an if statement that will check the category of an event. If the category matches certain criteria then the code will print out a message that does not include the date of the class. Otherwise, it will continue to print the current code: <p class="alert">You are registering for the <?php echo $event_name ?> event on <?php echo event_date_display($start_date, get_option('date_format')); ?></p>

I would like to make the category a variable, but I am unsure which table from the mysql database to call to get that information. Basically, I would like to create a variable that contains the value of the event’s category then compare that variable to something else and print out a message based on the result of the comparison.

In short; How do I get the category of an event into registration_page_display.php?


Dean

August 6, 2014 at 3:48 am

Hi James,

I’ll be honest and say I’m still not sure what you are trying to achieve, nor can I trace that message.

However, answering your question is easy enough.

In the registration_page_display.php an object is used called $event.

You can get the category ID’s associated with the event by using $event->category_id

This will return a comma separated string of ID’s, so you will likely need to explode it and then run through a foreach.

Doing a var_dump() on $event will show you what data is available to play with.


James Simon

August 6, 2014 at 6:05 am

Dean,

I apologize for my ambiguity, but you have still pointed me in the right direction! I will try this and get back to you. Thanks!


Dean

August 6, 2014 at 6:56 am

No problem! It’s not your fault, sometimes it’s hard to figure things out just by swapping forum posts, but we do our best!


James Simon

August 6, 2014 at 7:48 am

Hi Dean,

Thank you again for all your help. I tried $event->category_id and doing a var_dump($events) but I would receive NULL. I even tried to use the CATEGORY_NAME shortcode, which allowed me to get the name of the category, but it did not work if an event had multiple categories.
<?php echo do_shortcode('[CATEGORY_NAME event_id="'.$event->id.'"]');?>

After further research, we found the topic. This checked for the event’s category and I combined it with an if statement.

Here is my working code.

<?php //Checks the event category and displays message based on the category
$sql = "SELECT * FROM " . EVENTS_CATEGORY_REL_TABLE . " cr JOIN " . EVENTS_CATEGORY_TABLE . " c ON cr.cat_id = c.id WHERE cr.event_id = '" . $event_id . "' AND c.category_name = 'TestCategory'";
				$is_cat = $wpdb->get_row( $wpdb->prepare( $sql, NULL ), OBJECT);
				if (!empty($is_cat)) : ?>
					<p class="alert">You are registering for the <?php echo $event_name ?> event.</p>
				<?php else :?> 
					<p class="alert">You are registering for the <?php echo $event_name ?> event on <?php echo event_date_display($start_date, get_option('date_format')); ?>.</p>
				<?php endif; ?>


James Simon

August 6, 2014 at 7:49 am

This was the solution that was used.
https://eventespresso.com/topic/check-event-category-on-registration_page-php/

Viewing 7 reply threads

The support post ‘Changing an event registration alert to hide the date for a specific event’ is closed to new replies.

Have a question about this support post? Create a new support post in our support forums and include a link to this existing support post so we can help you.

Event Espresso