• Resolved coxinha

    (@coxinha)


    Dear all,

    I’m trying to add the template “my bookings” to a Ultimate Member’s custom account tab.

    Found following code snippet here in this support fourm which is over 2 years old:

    function em_shortcode_my_bookings() {
    	ob_start();
    	echo '<h2>' . esc_html__('My Bookings', 'events-manager') . '</h2>';
    	em_locate_template( 'templates/my-bookings.php', true );
    	$output = ob_get_clean();
    	return $output;
    }
    add_shortcode('my_bookings', 'em_shortcode_my_bookings');

    My problem: It doesn’t work (anymore?). The template has not been added.

    What did I wrong? Here the complete code I’m using:

    /* add new tab called "veranstaltung" */
    
    add_filter('um_account_page_default_tabs_hook', 'my_custom_tab_in_um3', 100 );
    function my_custom_tab_in_um3( $tabs ) {
    	$tabs[400]['veranstaltung']['icon'] = 'um-icon-calendar';
    	$tabs[400]['veranstaltung']['title'] = 'Veranstaltungen';
    	$tabs[400]['veranstaltung']['custom'] = true;
    	$tabs[400]['veranstaltung']['show_button'] = false;
    	return $tabs;
    }
    	
    /* make our new tab hookable */
    
    add_action('um_account_tab__veranstaltung', 'um_account_tab__mytab2');
    function um_account_tab__mytab2( $info ) {
    	global $ultimatemember;
    	extract( $info );
    
    	$output = $ultimatemember->account->get_tab_output('veranstaltung');
    	if ( $output ) { echo $output; }
    }
    
    /* Finally we add some content in the tab */
    
    add_filter('um_account_content_hook_veranstaltung', 'um_account_content_hook_mytab2');
    function um_account_content_hook_mytab2( $output ){
    	ob_start();
    	?>
    
    <div class="um-field-area">
    
    <div class="um-field um-field-newsletter um-field-select um-field-type_select" data-key="lilalaune">
    <span style="font-size: 16px!important;">Hier kannst Du alle Veranstaltungen sehen, für die Du Dich angemeldet bzw. Tickets gebucht hast.</span>
    </div>
    	
    	<?php
    
    function em_my_bookings_shortcode( $args = array() ){
    	ob_start();
    	em_locate_template('templates/my-bookings.php',true, array('args'=>$args));
    	return ob_get_clean();
    }
    add_shortcode ( 'my_bookings', 'em_my_bookings_shortcode');
    		?>
    
    	
    	
    
    </div>
    
    	
    	<?php
    
       $output .= ob_get_contents();
       ob_end_clean();
       return $output;	
    	
    }

    Thanks for your help in advance.

Viewing 2 replies - 1 through 2 (of 2 total)
  • Thread Starter coxinha

    (@coxinha)

    Sorry, I posted the wrong code. This is the correct one I’m using in my functions.php:

    /* add new tab called "veranstaltung" */
    
    add_filter('um_account_page_default_tabs_hook', 'my_custom_tab_in_um3', 100 );
    function my_custom_tab_in_um3( $tabs ) {
    	$tabs[400]['veranstaltung']['icon'] = 'um-icon-calendar';
    	$tabs[400]['veranstaltung']['title'] = 'Veranstaltungen';
    	$tabs[400]['veranstaltung']['custom'] = true;
    	$tabs[400]['veranstaltung']['show_button'] = false;
    	return $tabs;
    }
    	
    /* make our new tab hookable */
    
    add_action('um_account_tab__veranstaltung', 'um_account_tab__mytab2');
    function um_account_tab__mytab2( $info ) {
    	global $ultimatemember;
    	extract( $info );
    
    	$output = $ultimatemember->account->get_tab_output('veranstaltung');
    	if ( $output ) { echo $output; }
    }
    
    /* Finally we add some content in the tab */
    
    add_filter('um_account_content_hook_veranstaltung', 'um_account_content_hook_mytab2');
    function um_account_content_hook_mytab2( $output ){
    	ob_start();
    	?>
    
    <div class="um-field-area">
    
    <div class="um-field um-field-newsletter um-field-select um-field-type_select" data-key="lilalaune">
    <span style="font-size: 16px!important;">Hier kannst Du alle Veranstaltungen sehen, für die Du Dich angemeldet bzw. Tickets gebucht hast.</span>
    </div>
    	
    	<?php
    	
    	
    function em_shortcode_my_bookings() {
    	ob_start();
    	echo '<h2>' . esc_html__('My Bookings', 'events-manager') . '</h2>';
    	em_locate_template( 'templates/my-bookings.php', true );
    	$output = ob_get_clean();
    	return $output;
    }
    add_shortcode('my_bookings', 'em_shortcode_my_bookings');
    
    		?>
    
    	
    	
    
    </div>
    
    	
    	<?php
    
       $output .= ob_get_contents();
       ob_end_clean();
       return $output;	
    	
    }
    Thread Starter coxinha

    (@coxinha)

    Found the solution (life can be so simple):

    Just add Events Manager’s shortcode:

    <?php echo do_shortcode( "[my_bookings]"); ?>

Viewing 2 replies - 1 through 2 (of 2 total)
  • The topic ‘How to add shortcode for “My Bookings”?’ is closed to new replies.