Support

Home Forums Event Espresso Premium Custom event code

Custom event code

Posted: March 1, 2017 at 5:34 am

Viewing 3 reply threads


bku

March 1, 2017 at 5:34 am

Hi guys, it is taking me too long to figure this one out
please try to help

i’m trying to get 1 new event for the home page
if there are none, i get the last event.
this one works for me

i have a registration page that is password protected (from the way we have built it in version EE3

this page is under the EE4 settings as well

when i use the “espresso_event_reg_button” it gives me the link to the event and not the registration page

the event registration for EE3 was: http://www.domain.com/event-registration/?ee=1
when i try to use the same thing i get error:

The following errors have occurred:
The requested route 207 could not be mapped to any registered modules.
EE_Module_Request_Router - resolve_route - 139
Direct access to the registration checkout page is not allowed.
InvalidCheckoutAccess - checkoutAccessIsInvalid - 68

how can i change that?

<?php
$whereActive = array(
	'Datetime.DTT_EVT_end' => array( '>=', current_time( 'mysql' )),
	'status' => 'publish'
);

$whereOld = array(
	'Datetime.DTT_EVT_end' => array( '<=', current_time( 'mysql' )),
	'status' => 'publish'
);
// run the query
if ( class_exists( 'EE_Registry' ) ) : {
   $events = EE_Registry::instance()->load_model( 'Event' )->get_all( array(
	$whereActive,
	'limit' => 1,
	'order_by' => 'Datetime.DTT_EVT_start',
	'order' => 'asc',
	'group_by' => 'EVT_ID'
   ));

   if (  empty( $events )) {

   $events = EE_Registry::instance()->load_model( 'Event' )->get_all( array(
	$whereOld,
	'limit' => 1,
	'order_by' => 'Datetime.DTT_EVT_start',
	'order' => 'desc',
	'group_by' => 'EVT_ID'
   ));
   }
}

// the loop
if ( ! empty( $events )) {
//	echo '<ul>';
	foreach ( $events as $event ) {
		if ( $event instanceof EE_Event ) {
$EVT_ID = $event->ID();
//print_r ($event);
$times = EE_Registry::instance()->load_model('Datetime' )->get_all_event_dates( $event->ID() );
//print_r ($times);
$times_obj = current($times);
//print_r ($times_obj);
//echo $times_obj->date();
//echo '<br />';
  $test_obj = new ReflectionClass('EE_Datetime');
  $fields = $test_obj->getProperty('_fields');
  $fields->setAccessible(true);
//print_r ($fields);
//  $event_start = $fields->getValue($times_obj)['DTT_EVT_start'];
			echo '<div id="event_wrapper">';
			echo '<div id="event_container_pagination">';
			echo '      <div id="event_content" class="event_content">';
			echo '         <p id="events_category_name-1" class="events_category_name"></p>';
			echo '         <div id="event_data-1" class="event_data NULL  event-data-display event-list-display event-display-boxes ui-widget">';
			echo '            <h3 id="event_title-1" class="event_title ui-widget-header ui-corner-top"><a title="' . $event->name() . '" class="a_event_title" id="a_event_title-1" href="' . get_permalink( $event->ID() ) . '">' . $event->name() . '</a>';
			echo '            </h3>';
			echo '            <div class="event-data-display ui-widget-content ui-corner-bottom">';
			echo '               <div class="event-desc">';
			foreach(preg_split("/((\r?\n)|(\r\n?))/", $event->Description()) as $line){
			echo '                  <p>' . $line . '</p>';
			} 
			echo '               </div>';
			echo '               <div class="redend">';
			echo '                  October 28, 2015 ';
			echo '               </div>';
			echo '               <div class="event-meta clearfix">';
			echo '                  <p id="event_date-1"><span class="section-title">Date:</span>  ' . espresso_event_date('F j, Y','',$event->ID(), false) . '';
			echo '                  </p>';
			echo '               </div>';
			echo '               <p class="event_address" id="event_address-1"><span class="section-title">Address:</span> <br>';
			echo '                  <span class="address-block">';
			echo '                  company<br>city, country				</span>';
			echo '               </p>';
			echo '               <p id="register_link-1" class="register-link-footer">';
			echo espresso_event_reg_button('Register Now',false,$event->ID());
			echo '                  <a class="a_register_link ui-button ui-button-big ui-priority-primary ui-state-default ui-state-hover ui-state-focus ui-corner-all" id="a_register_link-1" href="http://www.domain.com/event-registration/?ee=1" title="2015 Course">View Details</a> 			';
			echo '               </p>';
			echo '            </div>';
			echo '         </div>';
			echo '      </div>';
			echo '   </div>';
//			echo '<h2><a href="' . get_permalink( $event->ID() ) . '">' . $event->name() . '</a></h2>';
			echo '</div>';
		}
	}
//	echo '</ul>';
} 
endif; ?>


Tony

  • Support Staff

March 1, 2017 at 3:48 pm

Hi there,

When posting code it’s much better to create a gist or use something like pastebin and include the link here as its much easier to view.

i have a registration page that is password protected (from the way we have built it in version EE3

What shortcode is in use on this page?

this page is under the EE4 settings as well

So the password protected page is set as the ‘Registration Checkout Page’ within EE4’s critical pages?

when i use the “espresso_event_reg_button” it gives me the link to the event and not the registration page

You can’t link directly to the checkout page with EE4 as you need to submit your ticket selections to ‘cart’ before you hit the checkout page.

You would need to load the ticket selector on the page rather than a button, take a look into the espresso_ticket_selector( $event ) function, you pass that function the EE_Event rather than just the ID.

That should load the ticket selector for you event, your use then select tickets from that page and submits the selection which will the direct the user to the cart.

the event registration for EE3 was: http://www.domain.com/event-registration/?ee=1
when i try to use the same thing i get error

None of the EE3 links will work with EE4 as it works in a completely different way. You need to use the ticket selector and submit the selection to the single page checkout (SPCO for short) which is the ‘Registration Checkout’ page.


bku

March 1, 2017 at 11:47 pm

So what can i do if i want to go back to EE3? we bought the EE4 and mailchimp
but it is too much to work on for changes

can i get the EE3 pro instead?


Tony

  • Support Staff

March 2, 2017 at 3:34 am

You can change you license from your account page, there is a dropdown that allows you to change license type there.

Or you could contact our sales department using this form:

https://eventespresso.com/contact/

Using the billing/account question radio button and provide the requested details.

Viewing 3 reply threads

The support post ‘Custom event code’ 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