Need help with the BuddyPress menu.

I added some code provided by one of your support people that allows me to add a custom menu item to the BuddyPress profile menu titled “Write Blog”. It worked and so I duplicated it to added another one called “My Posts”. Currently, this is what is seen when you click on the tab “My Posts”

https://cdn.livechat-static.com/api/file/v2/lc/att-old/8801096/4296aa94a422836ecb0b9b9fa92d716c/Buddypress%20Menu2.png

Instead of what is currently shown, I would like it to default to the “posts” tab that uses the URL:

https://jesusteam.com/members/joshuaballard/my-posts/?section=posts

But the link is relative to the user. The slug will vary according to the username. So if my username is “joshua” it will be /members/joshua/my-posts/?section=posts. Basically, the end is what matters. /?section=posts

Please help how can I achieve that.

  • Ash
    • Code Norris

    Hello Joshua

    The simplest way is to use javascript. In your other post, remember the last function – bp_custom_write_blog_cb()?

    Make some changes in that function like following:

    function bp_custom_write_blog_cb() {
    echo 'Text or shortcode for this tab';

    if( ! isset( $_REQUEST['section'] ) ) {
    ?>
    <script>
    window.location.href = window.location + '?section=posts';
    </script>
    <?php
    }
    }

    Let me know if it works for you. Have a nice day!

    Cheers,

    Ash