BuddyDev

Search

@mention autofill on custom dashboard page

  • Participant
    Level: Initiated
    Posts: 14
    Nicola Fern on #23507

    Hi

    I saw your helpful blog post on this topic: https://buddydev.com/enabling-buddypress-mention-auto-suggestions-on-any-page/

    I was wondering how I would amend this to work on a page I have – it functions as a member dashboard so has tabs, one of which has an activity shortcode and update box. The code example you gave in the blog post has:

    //modify this condition to suit yours
    if( is_user_logged_in() && bp_is_current_component( ‘mediapress’ ) ) {
    $load = true;

    – obviously I’m wanting this to work on a single page though so I guess the current_component bit needs to be different?

    Grateful for any help you can offer!

    Thanks
    Nic

  • Keymaster
    (BuddyDev Team)
    Posts: 24149
    Brajesh Singh on #23518

    Hi Nic,
    You may try this

    
    add_filter( 'bp_activity_maybe_load_mentions_scripts', 'buddydev_enable_mention_autosuggestions', 10, 2 );
     
    function buddydev_enable_mention_autosuggestions( $load, $mentions_enabled ) {
        
        if( ! $mentions_enabled ) {
            return $load;//activity mention is  not enabled, so no need to bother
        }
        //modify this condition to suit yours
        if( is_user_logged_in() ) {
            $load = true;
        }
        
        return $load;
    }
    

    That should do it on all pages.

    Regards
    Brajesh

You must be logged in to reply to this topic.

This topic is: not resolved