Universal Link to Asgaros Profile Page
Quote from Hawks Cast on April 17, 2021, 11:09 amI'm trying to customize things toward a mobile view since half of our users appear to be using their phones to view our site.
Is there a way to get a URL of the profile link within the Asgaros Menu and put that link in a Site Menu?
I want the Profile in the green forum menu to be placed in the site menu at the top.
I'm trying to customize things toward a mobile view since half of our users appear to be using their phones to view our site.
Is there a way to get a URL of the profile link within the Asgaros Menu and put that link in a Site Menu?
I want the Profile in the green forum menu to be placed in the site menu at the top.
Quote from qualmy91 on April 18, 2021, 7:23 amHey @hawks-cast,
you can use the following code to change a menu entry:
add_filter( 'nav_menu_link_attributes', 'asgaros_menu_profile', 10, 3 ); function asgaros_menu_profile( $atts, $item, $args ) { if (!strpos($atts['href'], '--asgaros-profile--')) { return $atts; } $user = wp_get_current_user(); $profile_link = home_url() . "/forum/profile/" . $user->user_nicename; $atts['href'] = $profile_link; return $atts; }After adding this code you only have to add "--asgaros-profile--" to the URL of the menu entry and it will be replaced with the profile link.
Hey @hawks-cast,
you can use the following code to change a menu entry:
add_filter( 'nav_menu_link_attributes', 'asgaros_menu_profile', 10, 3 ); function asgaros_menu_profile( $atts, $item, $args ) { if (!strpos($atts['href'], '--asgaros-profile--')) { return $atts; } $user = wp_get_current_user(); $profile_link = home_url() . "/forum/profile/" . $user->user_nicename; $atts['href'] = $profile_link; return $atts; }
After adding this code you only have to add "--asgaros-profile--" to the URL of the menu entry and it will be replaced with the profile link.