Last active
June 8, 2023 00:43
-
-
Save hivepress/1bc1ae12d9cb34a90bb6024163365098 to your computer and use it in GitHub Desktop.
Add vendor profile link to the user account menu #hivepress #vendors
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?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