Advertisement
arie_cristianD

add custom menu to my account page

Feb 19th, 2025
87
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
PHP 0.97 KB | None | 0 0
  1. add_filter(
  2.     'jnews_account_page_endpoint',
  3.     'add_custom_account_menu',
  4.     99
  5. );
  6.  
  7. function add_custom_account_menu( $enpoint ) {
  8.  
  9.     /* add custom menu on account menu item  */
  10.     $enpoint['custom_account_menu'] = array(
  11.         'slug'  => 'custom-menu',  /* custom menu slug */
  12.         'label' => 'custom_menu',
  13.         'title' => esc_html__( 'Custom Menu', 'jnews' ),  /* custom menu Title */
  14.     );
  15.  
  16.     return $enpoint;
  17. }
  18.  
  19.  
  20. add_action( 'jnews_account_right_content', 'custom_account_menu' );
  21.  
  22. function custom_account_menu() {
  23.     global $wp;
  24.  
  25.     if ( is_user_logged_in() ) {
  26.         if ( isset( $wp->query_vars['account'] ) && ! empty( $wp->query_vars['account'] ) ) {
  27.             $query_vars = explode( '/', $wp->query_vars['account'] );
  28.  
  29.             if ( 'custom-menu' === $query_vars[0] ) {
  30.                 $render_page = 11818;   /* change with  your custom page ID */
  31.                 $page        = get_post( $render_page );
  32.  
  33.                 if ( $page ) {
  34.                     echo apply_filters( 'the_content', $page->post_content );
  35.                 }
  36.             }
  37.         }
  38.     }
  39. }
  40.  
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement