Adding a menu item

Silly questions, but how do I add a menu item to take a user to wp/members/admin/ or specifically wp/members/”their account name”/

  • Rupok
    • Ex Staff

    Hi Marzie, hope you had a wonderful day.

    If you are using BuddyPress, then you can get idea from this page: https://buddypress.org/support/topic/add-my-profile-link-to-main-nav/

    If you are trying to manually add profile links, then you need to create a MU Plugin. For creating a MU Plugin, create a folder named “mu-plugins” inside your “wp-content” folder. Then inside that “mu-plugins” folder, create a file with any name and with a .php extension. Now paste the code inside that file and save.

    <?php
    function custom_profile_link() {
    global $current_user;
    $current_user = wp_get_current_user();
    echo '<a href="http://yoursite.com/members/their account name/' . $current_user->user_login . '">'.Anchor Text.'</a>';
    }
    add_shortcode( 'userlink', 'custom_profile_link' );

    For getting more idea on mu plugins, you can go through this article: http://wpmudev.com/manuals/wpmu-manual-2/using-mu-plugins/

    This will add a shortcode “[userlink]” which you can use anywhere and return your username with link.

    If you want to add this in your custom menu, you can check this guide: http://www.wpbeginner.com/wp-themes/how-to-add-custom-items-to-specific-wordpress-menus/

    Please let us know if you have any confusion. We will be glad to help further if required.

    Have a nice day. Cheers!

    Rupok

  • Marzie
    • Design Lord, Child of Thor

    I will try this as a second option if you tell me this other option is more complicated. In on of the solutions posted in the link you provided, the simplest solution seemed to be to select the Buddypress menu from the top……

    “If you don’t see Buddypress in Dashboard > Appearance > Menus make sure you check your Screen Options at the top of the page.”

    I did that but got the following error. Fatal error: Call to a member function get_primary() on a non-object in /home1/”mydirectory”/public_html/wp/wp-content/plugins/buddypress/bp-core/bp-core-functions.php on line 2471

    If that’s an easy enough fix, this would be the easiest route. Thank you, so much for your quick response

  • Nithin Ramdas
    • Support Wizard

    Hi Marzie,

    Hope you are doing good today. :slight_smile:

    I did that but got the following error. Fatal error: Call to a member function get_primary() on a non-object in /home1/”mydirectory”/public_html/wp/wp-content/plugins/buddypress/bp-core/bp-core-functions.php on line 2471

    I checked your website, how can I replicate this? I tried to add a menu item, but it works fine, is it related to a specific item?

    This is definitely a plugin conflict, would recommend you to please run a quick plugin/theme conflict test as illustrated in getting support manual (flowchart), and rule out whether any plugin/theme is causing this issue.

    http://wpmudev.com/manuals/using-wpmu-dev/getting-support/

    Please let us know how that goes, have a nice day. :slight_smile:

    Kind Regards,

    Nithin