Is there any way to get forum root slug field value?
-
Hi, I am trying to add forum user profile link into wp_nav_menu_items.
Is there any way to get the forum root slug field value dynamically (just like user nickname, see $user in below code) to making the profile link dynamic? I am thinking to adding a setting option for getting the forum root slug from users in case no way to get the forum root slug fieled value.Could anyone help? Thanks in advance.
/** * Add bbp user profile link in WP nav menu * Filter wp_nav_menu() to add profile link */ function prefix_bbp_profile_link_nav_menu($menu) { if ( !is_user_logged_in() ) return $menu; else $home_url = home_url( '/' ); $current_user = wp_get_current_user(); $user = $current_user->user_nicename ; $profilelink = '<li> <a href="' . esc_url( $home_url ) . '/forum-slug/users/' . $user . '/edit"> '. __('Edit Profile', 'text-domain' ) .' </a> </li>'; $menu = $menu . $profilelink; return $menu; } add_filter( 'wp_nav_menu_items', 'prefix_bbp_profile_link_nav_menu' );
Viewing 2 replies - 1 through 2 (of 2 total)
Viewing 2 replies - 1 through 2 (of 2 total)
- You must be logged in to reply to this topic.