|
| 1 | +<?php |
| 2 | +/* |
| 3 | +Plugin Name: Member purchases view in Ultimate Member. |
| 4 | +Plugin URI: http://www.joedolson.com/my-tickets/ |
| 5 | +Description: Add a tab in Ultimate Member where members can view their purchased tickets. |
| 6 | +Version: 1.0.0 |
| 7 | +Author: Johan Hulsmans |
| 8 | +Author URI: n/a |
| 9 | +*/ |
| 10 | + |
| 11 | +/** |
| 12 | + * Set up a custom tab in Ultimate Member. |
| 13 | + * |
| 14 | + * @param array $tabs Array of existing member tabs. |
| 15 | + * |
| 16 | + * @return array |
| 17 | + */ |
| 18 | +function my_custom_tab_in_um( $tabs ) { |
| 19 | + $tabs[800]['mytab']['icon'] = 'um-faicon-ticket'; |
| 20 | + $tabs[800]['mytab']['title'] = 'Orders'; |
| 21 | + $tabs[800]['mytab']['show_button'] = false; |
| 22 | + $tabs[800]['mytab']['custom'] = true; |
| 23 | + |
| 24 | + return $tabs; |
| 25 | +} |
| 26 | +add_filter( 'um_account_page_default_tabs_hook', 'my_custom_tab_in_um', 100 ); |
| 27 | + |
| 28 | +/** |
| 29 | + * Make our new tab hookable. |
| 30 | + */ |
| 31 | +function um_account_tab__mytab( $info ) { |
| 32 | + global $ultimatemember; |
| 33 | + extract( $info ); |
| 34 | + |
| 35 | + $output = $ultimatemember->account->get_tab_output('mytab'); |
| 36 | + if ( $output ) { |
| 37 | + echo $output; |
| 38 | + } |
| 39 | +} |
| 40 | +add_action( 'um_account_tab__mytab', 'um_account_tab__mytab' ); |
| 41 | + |
| 42 | +/** |
| 43 | + * Finally we add some content in the tab. |
| 44 | + * |
| 45 | + * @param string $output Default tab output. |
| 46 | + * |
| 47 | + * @return string |
| 48 | + */ |
| 49 | +function um_account_content_hook_mytab( $output ){ |
| 50 | + ob_start(); |
| 51 | + ?> |
| 52 | + <div class="um-field"> |
| 53 | + <!-- Here goes your custom content --> |
| 54 | + <?php echo do_shortcode( '[my-payments]' ); ?> |
| 55 | + </div> |
| 56 | + <?php |
| 57 | + $output .= ob_get_contents(); |
| 58 | + ob_end_clean(); |
| 59 | + |
| 60 | + return $output; |
| 61 | +} |
| 62 | +add_filter( 'um_account_content_hook_mytab', 'um_account_content_hook_mytab' ); |
0 commit comments