[Events +] How can i get the values of the Event+ custom fields

I'd like to create a template-page with beaver themer. There for i must know the names of the Meta Fields, containing the custom values of the event, like date and time, price, open places, places total, venue, teacher etc...
Or is there another way, to access these fields? Shortcut?

  • Adam Czajczyk

    Hello Laskaric

    I hope you're well today and thank you for your question!

    There's no shortcodes to access that data specifically and directly, I'm afraid.

    However, events are custom posts of "insub_event" type so to get basic information (title, description, published date, featured image... - all the standard post data) you just need to query for the "incsub_event" custom post type. I'm not sure how that works in Beaver Builder but any tool that let's you set/create query for custom posts (as well as custom coded template) would let you do this.

    As for additional data, such as price, venue etc. These are custom fields associated with "incsub_event" custom post type, the basic ones would be:

    incsub_event_status (that's the status: open, closed, expired, archived)
    incsub_event_paid (whether it's paid or not)
    incsub_event_fee (that's the price)
    incsub_event_venue (venue information)

    incsub_event_start
    incsub_event_no_start (if there's no start time)
    inscub_event_end
    incsub_event_no_end (if there's no end time)

    so fetching that meta data for a given post ID would give you those information.

    Having that said, I'm not sure what options Beaver Builder gives you if it comes to handling custom post types/post meta data so it might be necessary to have some additional code custom developed. In case you'd need some custom development, consider post a question on our "Jobs & Pros" job board (please note: no WPMU DEV staff involved!) here:

    https://premium.wpmudev.org/wordpress-development/

    Best regards,
    Adam

  • Adam Czajczyk

    Hello Laskaric

    incsub_event_start is a timestamp?

    No, it's just a string, containing a date like e.g. "2018-09-28 22:00:00".

    How is it solved with events with multiple occurrences? Array?

    Recurring events are actually separate events as well. The "parent" event in this case has additional meta keys:

    "eab_event_recurrence_starts" - which is a timestamp (indicating first occurrence)
    "eab_event_recurrence_ends" - timestamp again
    "eab_event_recurring" - which has a verbal value like e.g. "daily"
    "eab_event_recurrence_parts" - which is a serialized array

    The way it's displayed is handled by the plugin code then but I'm not aware of more details as I'm not the developer. I'm afraid that I'm also not able to tell you "what do you have to call, if you want to send the shown event to cart".

    I'd assume that "sending event to cart" would depend on what e-commerce plugin are you using (e.g. in MarketPress which is the only one that has integration with Events+, the events don't actually go to the cart, instead there's a product assigned to a paid event that attendee buys).

    I've asked one of our developers to take a look at your questions, so hopefully he could give you some additional tips but please note that it might take a bit more for him to respond (than it takes me here on forum) and that since there's no hooks/template tags for these aspects of Events+, we cannot provide you with a ready to use code.

    Best regards,
    Adam

  • Panos

    Hi Laskaric ,

    Not sure how Beaver builder works but I would suggest to create a custom shortcode that would load any meta info you need from an event. As Adam already mentioned this is custom job that exceeds the purpose of our support forum and I would suggest to hire a dev from the jobs board.

    In case you are familiar with php and feel confident with coding I would like to provide a custom shortcode which you can use as a guide:

    function incsub_event_sc( $atts ) {
    
    	$atts = shortcode_atts(
    		array(
    			'event_id' => null,
    		),
    		$atts, 'incsub_event_sc_atts'
    	);
    
    	if( ! class_exists( 'Eab_EventModel' ) ) {
    		return;
    	}
    
    	global $blog_id, $wp_query, $booking, $post, $current_user;
    
    	if( ! is_null( $atts[ 'event_id' ] ) ) {
    		$post = get_post( (int) $atts[ 'event_id' ] );
    	}
    
    	$event 		= new Eab_EventModel($post);
    	$start_day 	= date_i18n('m', strtotime(get_post_meta($post->ID, 'incsub_event_start', true)));
    
    	ob_start();
    	?>
    	<div id="primary">
    		<div id="content" role="main">
                <div class="event <?php echo Eab_Template::get_status_class($post); ?>" id="wpmudevevents-wrapper">
    				<div id="wpmudevents-single">
    
    					<div class="wpmudevevents-header">
                            <h2><?php echo $event->get_title(); ?></h2>
                            <div class="eab-needtomove"><div id="event-bread-crumbs" ><?php echo Eab_Template::get_breadcrumbs($event); ?></div></div>
                            <?php
                            echo Eab_Template::get_rsvp_form( $post );
    						echo Eab_Template::get_inline_rsvps( $post );
                            ?>
                        </div>
    
                        <hr />
    
                        <?php
    
                        if ($event->is_premium() && $event->user_is_coming() && !$event->user_paid()) { ?>
    					    <div id="wpmudevevents-payment">
    						<?php _e('You haven\'t paid for this event', Eab_EventsHub::TEXT_DOMAIN); ?>
    			            <?php echo Eab_Template::get_payment_forms( $post ); ?>
    					    </div>
                        <?php } ?>
    
                        <?php echo Eab_Template::get_error_notice(); ?>
    
                         <div class="wpmudevevents-content">
    						<div id="wpmudevevents-contentheader">
                                <h3><?php _e('About this event:', Eab_EventsHub::TEXT_DOMAIN); ?></h3>
    
    			   				 <div id="wpmudevevents-user"><?php _e('Created by ', Eab_EventsHub::TEXT_DOMAIN); ?><?php the_author_link();?></div>
    						</div>
    
                            <hr />
    
                            <div class="wpmudevevents-contentmeta">
                                <?php echo Eab_Template::get_event_details($post); //event_details(); ?>
    						</div>
    
    						<div id="wpmudevevents-contentbody">
    			    		<?php
    			    			add_filter('agm_google_maps-options', 'eab_autoshow_map_off', 99);
    					    	echo $event->get_content();
    							remove_filter('agm_google_maps-options', 'eab_autoshow_map_off');
    					    ?>
    			    		<?php if ($event->has_venue_map()) { ?>
    			    			<div class="wpmudevevents-map"><?php echo $event->get_venue_location(Eab_EventModel::VENUE_AS_MAP); ?></div>
    			   			<?php } ?>
                            </div>
                            <?php comments_template( '', true ); ?>
                        </div>
    
    				</div>
    			</div>
    		</div>
    	</div>
    
    	<?php
    	get_footer('event');
    	$out = ob_get_clean();
    
    	return $out;	
    
    }
    
    add_shortcode( 'incsub_event_sc', 'incsub_event_sc' );

    This snippet should be creating a new shortcode [incsub_event_sc]. You can also use the event_id when adding that shortcode in pages that are not events: [incsub_event_sc event_id="5115"].

    This should print some default layout which you can modify as you need.

    Hope this helps :slight_smile:

    Cheers!

Thank NAME, for their help.

Let NAME know exactly why they deserved these points.

Gift a custom amount of points.