Advertisement
phpface

Add custom tab to user settings menu

Oct 1st, 2022 (edited)
1,209
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
PHP 0.83 KB | None | 0 0
  1. /**
  2.  *
  3.  * Add custom tab to user settings menu
  4.  *
  5.  * @param array $menu
  6.  *
  7.  */
  8. add_filter( 'streamtube/core/user/dashboard/menu/items', function( $menu ){
  9.  
  10.     $tab = array(
  11.         'slug'      =>  'custom-tab',
  12.         'text'      =>  esc_html__( 'Custom Tab', 'streamtube' ),
  13.         'icon'      =>  'icon-star'
  14.     );
  15.  
  16.     /**
  17.      * Declare menu icon class
  18.      * @link https://streamtube.marstheme.com/icons/
  19.      */
  20.     $menu_icon = 'icon-star';
  21.  
  22.     $menu['settings']['submenu'][ $tab['slug'] ] = array(
  23.         'title'     =>  $tab['text'],
  24.         'icon'      =>  $tab['icon'],
  25.         'callback'  =>  function(){
  26.             ?>
  27.             <!-- Custom Content -->
  28.  
  29.             <p>
  30.                 Hello World
  31.             </p>
  32.  
  33.  
  34.             <?php
  35.  
  36.             // For instance, print current logged in username using shortcode
  37.            
  38.             echo do_shortcode( '[user_name user_id="logged_in"]' );
  39.         },
  40.         'priority'  =>  100
  41.     );
  42.  
  43.     return $menu;
  44. }, 10, 1 );
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement