Skip to content

Instantly share code, notes, and snippets.

@hivepress
Last active June 8, 2023 00:43
Show Gist options
  • Star 1 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save hivepress/1bc1ae12d9cb34a90bb6024163365098 to your computer and use it in GitHub Desktop.
Save hivepress/1bc1ae12d9cb34a90bb6024163365098 to your computer and use it in GitHub Desktop.
Add vendor profile link to the user account menu #hivepress #vendors
<?php
add_filter(
'hivepress/v1/menus/user_account',
function ( $menu ) {
if ( is_user_logged_in() ) {
$vendor_id = HivePress\Models\Vendor::query()->filter(
[
'user' => get_current_user_id(),
]
)->get_first_id();
if ( $vendor_id ) {
$menu['items']['vendor_view'] = [
'label' => 'Vendor Profile',
'url' => hivepress()->router->get_url( 'vendor_view_page', [ 'vendor_id' => $vendor_id ] ),
'_order' => 123,
];
}
}
return $menu;
},
1000
);
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment