Okay, I figured out a workaround for anybody that is interested.
Step 1: Make an “Account” page using the /account/
slug as a placeholder. It won’t do anything. Just call it what you want.
Step 2: Make the page(s) you want to add to your account area as normal pages, with the “Account” page you created as the parent so that it follows the same url structure (/account/my-events/
).
Step 3: Edit the page(s) in the block editor like you would a template. Basically, add a column block with 1/3 on the left side and 2/3 on the right side. On the left side, add a shortcode that we will be creating: [sl_account_sidebar]
. On the right side, add a “Heading” block for the title, call it what you want, set it to H1, and add “content-title” to the custom classes. It will then match the theme titles. Below that, add your content, and save.
Step 4: Duplicate the menu in the menu section, including your custom page(s):
Make note of the menu id found in the url query string (ie. /wp-admin/nav-menus.php?menu=82
)
Step 5: Use the following code to get the link on the account menu. I have my custom code in a class, so I am using “public function” and calling it from my constructor with [ $this, 'account_sidebar' ]
. If you are not using a class, just remove “public”, and call it with 'account_sidebar'
instead.
add_filter( 'hivepress/v1/menus/user_account', [ $this, 'my_account_sidebar' ], 10, 2 );
public function my_account_sidebar( $props, $menu ) {
return hivepress()->helper->merge_arrays( $props, [
'items' => [
'my_events' => [
'label' => esc_html__( 'Events', 'hivepress' ),
'url' => '/account/my-events/',
'_order' => 11,
]
]
] );
} // End account_sidebar()
Step 6: Create our shortcode for the sidebar:
add_shortcode( 'sl_account_sidebar', [ $this, 'display_account_sidebar' ] );
public function display_account_sidebar() {
// Menu id (the one you made note of earlier)
$menu_id = 82;
// Get the menu items
$menu = wp_get_nav_menu_items( $menu_id );
// If found?
if ( is_user_logged_in() && !empty( $menu ) ) {
// The sidebar
$results = '
<aside class="sl-sidebar hp-page__sidebar site-sidebar" data-component="sticky" style="height: 100% !important;">
<nav class="hp-widget widget widget_nav_menu hp-menu hp-menu--user-account">
<ul>';
// Now iter the links, including the vendor profile
foreach ( $menu as $item ) {
// Check if current
$current_page = get_the_permalink( get_the_ID() );
if ( $current_page == $item->url ) {
$current_class = ' hp-menu__item--current current-menu-item';
} else {
$current_class = '';
}
// The link
$results .= '<li class="menu-item hp-menu__item hp-menu__item--vendor-view'.$current_class.'"><a href="'.$item->url.'"><span>'.$item->title.'</span></a></li>';
}
$results .= '</ul>
</nav>
</aside>';
// Return
return $results;
}
return false;
} // End display_account_sidebar()
I think that’s it. If you have any questions, let me know.