This topic has 8 replies, 3 voices, and was last updated 11 years by SQadmin.

  • Author
  • #1910
     Cenk
    Participant

    Hi!

    Do you know how to add dynamic buddypress profile links to the wp-menu?
    I only know how to import the profile page.

    So I put the following code in the functions.php.

    COPY CODE
    
        // Filter wp_nav_menu() to add profile link
        add_filter( 'wp_nav_menu_items', 'my_nav_menu_profile_link' );
        function my_nav_menu_profile_link($menu) {      
                if (!is_user_logged_in())
                        return $menu;
                else {
                        $profilelink = '<li><a href="' . bp_loggedin_user_domain( '/' ) . '">' . __('Profile') . '</a></li>';
                        $menu = $menu . $profilelink;
                        return $menu;
                 }
        }
    

    And it works.

    I would also like to add the other bp profile links to the wp-menu, but don’t know how.
    – Messages page
    – Friends page

    Thank you for your support.

    #1924
     SQadmin
    Keymaster

    Hi,
    After:

    COPY CODE
    
    $profilelink = '<li><a href="' . bp_loggedin_user_domain( '/' ) . '" rel="nofollow">' . __('Profile','buddypress') . '</a></li>';
    

    you can add another menus like this:

    COPY CODE
    
    $profilelink .= '<li><a href="' . bp_loggedin_user_domain( '/' ) . 'messages" rel="nofollow">' . __('Messages','buddypress') . '</a></li>';
    $profilelink .= '<li><a href="' . bp_loggedin_user_domain( '/' ) . 'friends" rel="nofollow">' . __('Friends','buddypress') . '</a></li>';
    
    Hi there!!! Help others from the community and mark any reply as solution if it solved your question. Mark as a solution
    #1930
     kswift
    Participant

    Nice, I would use this! Is there any way to move these items into a dropdown with submenu? Each item on their own within my menu will make the menu very long (across two lines)

    #1944
     Cenk
    Participant

    Thanks! I would like to replace the text with an image/icon. I tried it in Css. But it doesn’t work properly.

    Example: I traced the messages (menu) link with firebug and adjust it in Css

    COPY CODE
    
    div.kleo-page header div.header-bg div#header div.row div.eight div.contain-to-grid nav.top-bar section ul#menu-new-menu.left li a{ background-position: left; background-repeat: no-repeat; background-image:url(http://…..com/wp-content/uploads/2013/08/messagesicon.svg) } 
    

    But then the other dynamic links get the same icon image. I can’t do it separately.
    Is there a way to adjust it in the functions.php?

    COPY CODE
    
    $profilelink .= '<li><a href="' . bp_loggedin_user_domain( '/' ) . 'messages" rel="nofollow">' . __('Messages','buddypress') . '</a></li>'; 
    

    (removing the text “messages” ..and replacing it with an icon image…doesn’t work this way)

    COPY CODE
    
    $profilelink .= '<li><a href="' . bp_loggedin_user_domain( '/' ) . 'messages" rel="nofollow">' . __('background-image:url(http://......com/wp-content/uploads/2013/08/messagesicon.svg)','buddypress') . '</a></li>'; 
    

    I really appreciate your support. And is there a way to disable the menu hover?…or making it transparent.
    I want to place the two notification pop-up icons ontop of the wp-menu tabs.

    Thanks!

    #1951
     SQadmin
    Keymaster

    Hi kswift,
    Here is a sample from an existing dropdown. You can create yours the same way:

    COPY CODE
    
    <li class="has-dropdown" ><a class="main-menu-link" href="#">Buddypress</a>
    <ul class="dropdown"><li><a href="#" class="parent-link hide-for-large-up">Buddypress</a></li>
    	<li><a class="sub-menu-link" href="http://seventhqueen.com/demo/sweetdatewp/members/">Members</a></li>
    	<li><a class="sub-menu-link" href="http://seventhqueen.com/demo/sweetdatewp/groups/">Groups</a></li>
    	<li><a class="sub-menu-link" href="http://seventhqueen.com/demo/sweetdatewp/activity/">Activity</a></li>
    </ul>
    </li>
    
    Hi there!!! Help others from the community and mark any reply as solution if it solved your question. Mark as a solution
    #1952
     SQadmin
    Keymaster

    Hi,
    You cant do that (3rd pasted code). Your using css as html.
    Give your link a specific class and apply the css to it(this way it won’t apply to all links)
    CSS:

    COPY CODE
    
    div.kleo-page header div.header-bg div#header div.row div.eight div.contain-to-grid nav.top-bar section ul#menu-new-menu.left li a.my-message-class {...}
    

    PHP:

    COPY CODE
    
    $profilelink .= '<li><a class="my-message-class" href="' . bp_loggedin_user_domain( '/' ) . 'messages" rel="nofollow">' . __('Messages','buddypress') . '</a></li>'; 
    
    Hi there!!! Help others from the community and mark any reply as solution if it solved your question. Mark as a solution
    #1959
     Cenk
    Participant

    Thanks again. It works! I’m learning a lot:) I managed to disable the menu hover. But now I’m wondering how to put the two notification pop-up buttons on top of the menu button….that means first clickable.. (think in layers)
    At the moment they are behind the wp-menu buttons…(background)

    #1962
     Cenk
    Participant

    I’ve just noticed that the menu position is slightly different in Firefox .
    Safari and Chrome are the same.

    #1971
     SQadmin
    Keymaster

    I don’t think that existing notifications qualify to be displayed in the menu that way.

    Hi there!!! Help others from the community and mark any reply as solution if it solved your question. Mark as a solution
Viewing 9 posts - 1 through 9 (of 9 total)

The forum ‘Sweetdate – WordPress’ is closed to new topics and replies.

Log in with your credentials

Forgot your details?