Skip to:
Content
Pages
Categories
Search
Top
Bottom

Adding Dynamic Profile Link to Main Menu Item

Viewing 25 replies - 26 through 50 (of 58 total)

  • toccia
    Participant

    @toccia

    Ciao guys, my theme does not work with menus, so do you know how to get a link to the logged in user profile to be used wherever?


    @mercime
    Participant

    @mercime

    add_filter( 'wp_nav_menu_items', 'my_nav_menu_profile_link' );
    function my_nav_menu_profile_link($menu) { 	
    	if (!is_user_logged_in() && $args->theme_location == 'footer-nav' ) 
    		return $menu;
    	else
    		$profilelink = '<li><a href="' . bp_loggedin_user_domain( '/' ) . '">' . __('My Profile', 'buddypress' ) . '</a></li>';
        		$menu = $profilelink . $menu;
        		return $menu;
    }

    Formbi
    Participant

    @formbi

    Hey guys,

    I’ve tried both the code and plugin and neither is working…

    I am using a child them of bp default, with nothing much changed apart from some CSS etc.

    Maybe one of the plugin I am using is conflicting? I have installed BudyPress Album, Couterize, Invite Anyone, Socialize, WP-FB-Autoconnect.

    Any idea what’s going on??


    9087877
    Inactive

    Hi @formbi as @modemlooper already addressed he is going to be updating the plugin so maybe its best to wait until its done and it will resolve your issue.


    modemlooper
    Moderator

    @modemlooper

    Working on this today so expect an update very soon


    ript247
    Participant

    @ript247

    @mercime I just finished pluging in the code for a user profile page and I am having the same issue the link to main menu was not automatically created. I have been reading the post for the next steps and I am not sure what to do from here. Could you please explain how to get the profile page to link to main menu items. I am using bp community theme.


    ript247
    Participant

    @ript247

    Im sorry using simple wp community


    modemlooper
    Moderator

    @modemlooper


    ript247
    Participant

    @ript247

    Thanks for response @modemlooper I just switched to the community theme I like it so far, going to play around with it a little. Does this plugin work for this theme also? or do I have to add the above mentioned code?


    ript247
    Participant

    @ript247

    @mercime / @modemlooper installed plugin still no user profile page generated/ also tried the code nothing. I must be doing something wrong, can you PLEASE help


    modemlooper
    Moderator

    @modemlooper

    Plugin doesn’t create pages. Make sure you’ve created your component pages in wp admin. Settings > BuddyPress > Pages


    ript247
    Participant

    @ript247

    I created a wp page titled “My Profile” but it is not creating buddypress component directory just a page. Which is what I thought the suggested code would do.


    modemlooper
    Moderator

    @modemlooper

    You do not need to create every page. Just the component directories.

    Are you using a BP compatible theme?


    ript247
    Participant

    @ript247

    I am very sure. I am not having a problem making the profile page a home page, My problem is making “My Profile” show up in my component directories. On my components page it says “Associate a WordPress Page with each BuddyPress component directory” I would like to add “My Profile” to this component directory.

    Currently I have “Activity Stream = activity, Discussion Forum = Forums, Groups = Groups etc..

    How can I do this, sorry my english not so good sometimes.


    modemlooper
    Moderator

    @modemlooper

    I’m a bit confused but the members directory will not show a single users profile. The members page you create in admin is the sites directory for members. The profile page is located after this directory.

    /members/ = members directory
    /members/[user_name]/ = user profile

    You do not create this page. BP knows what page to use when you are on /members/[user_name]/

    Do you not have a page when you click a username link on your site?


    sensibleplugins
    Participant

    @sensibleplugins

    The BuddyPress Custom Profile Menu plugin should really help you out with this: https://wordpress.org/extend/plugins/buddypress-custom-profile-menu

    (full disclosure: it’s our plugin :) )


    Marcel Oerlemans
    Participant

    @marceloerlemans

    Hello,

    Thanks for the great work and help! I added the menu item and it works perfect, but only for the desktop version of the website. I’ve installed a responsive template, and when visiting the website on mobile, but also with making the desktop version smaller to mobile view, the menu item disappears!
    I don’t know if it’s possible to fix this, but it would be very nice. It would also be good if a profile button could appear in a widget area, however, in the menu would be best.

    I hope someone can help me out. Thanks in advance!

    Regards, Marcel


    kimi.keith
    Participant

    @kimikeith

    How did you manage to move the menu item to another location besides first or last? @modemlooper, that link to your plugin is not working anymore. I tried Buddypress custom profile menu but I am not using the Top Menu.


    bp-help
    Participant

    @bphelp

    @mercime I tried the code you provided and it works good, only one tiny problem if you can provide a fix. When I am on the activity page for instance then I click the link for View Your Awesome Profile it takes me there as it should but the activity menu item still looks active by the color of the menu item. Its probably a CSS thing but when your active in your profile the navigation menu item still looks like the activity menu item is the active because its still got the color of being the active item even though its not. Hope this makes sense. Any suggestions on how to fix it? Thank you!


    bp-help
    Participant

    @bphelp

    @mercime Any idea for a fix? Thank you!


    katemgilbert
    Participant

    @katemgilbert

    I have followed your suggestion to add the Profile link to a second theme location menu. However, now it shows in both menus. How can I specify it just to show in one and not the other? Here is my code:

    add_filter( 'wp_nav_menu_items', 'my_nav_menu_profile_link' );
    function my_nav_menu_profile_link($menu) { 	
    	if (!is_user_logged_in() && $args->theme_location == 'footer-nav' ) 
    		return $menu;
    	else
    		$profilelink = '<li><a href="' . bp_loggedin_user_domain( '/' ) . '">' . __('My Profile', 'buddypress' ) . '</a></li>';
        		$menu = $profilelink . $menu;
        		return $menu;
    }

    Thanks!


    jannmirch
    Participant

    @jannmirch

    @katemgilbert

    Don’t know if you came up with a fix for this but here’s what I did…

    I used the code as you posted it (based on my menus…) and added a style sheet for the other menus to not display that menu item. A hack I know but I searched high and low for a proper solution and didn’t find one.

    #menu-primary-menu .bpprofile, #menu-sidebar .bpprofile {
    	display:none;
    }
    

    damienoneill2001
    Participant

    @damienoneill2001

    Hi @mercime,

    I hope you can help with this.

    I have slightly altered code that you put up a year ago but am having a slight problem with it.

     // Filter wp_nav_menu() to add profile link
        add_filter( 'wp_nav_menu_items', 'my_nav_menu_profile_link',10,2 );
        function my_nav_menu_profile_link($menu, $args) {      
                if( is_user_logged_in() && $args->theme_location == 'header2' ){
            $profilelink = '<li>Welcome, <a href="' . bp_loggedin_user_domain( '/' ) . '">' . bp_loggedin_user_username() . '</a></li>';
            $menu = $menu . $profilelink;
        }
        return $menu;
        }

    Basically, I am hoping for the menu item to simply say Welcome, **Username**.

    At the moment, it is displaying the username, but is actually removing it from the a tags and from the actual menu itself, so the code reads something like:

    <nav id="other-navigation" class="top-navigation" role="navigation">
        username
            <div class="menu-secondary-header-menu-container">
                <ul id="menu-secondary-header-menu" class="header_menu_2">
                    <li id="menu-item-1865" class="menu-item-1865"> This is the first Link in the menu</li>
                    <li>Welcome, <a href="http://www.mysite.com/profile/username/"></a></li>
                </ul>
            </div>
    </nav>

    Hopefully you can shed some light onto this?

    Cheers

    Damien


    shanebp
    Moderator

    @shanebp

    Try using: bp_get_loggedin_user_username() instead of bp_loggedin_user_username().

    bp_loggedin_user_username() will echo the name so it will be out of the sequence you expect.


    damienoneill2001
    Participant

    @damienoneill2001

    @shanebp,

    Thats great!

    This worked a treat for me!

    Damien

Viewing 25 replies - 26 through 50 (of 58 total)
  • The topic ‘Adding Dynamic Profile Link to Main Menu Item’ is closed to new replies.
Skip to toolbar