BuddyDev

Search

[Resolved] Detect if user has media in gallery?

  • Participant
    Level: Enlightened
    Posts: 31
    Brian on #5069

    Hello,

    Trying to create an if statement which detects if a user on buddypress profile has media uploaded to a gallery, and if not, display a notice alert message.

    Is there a template tag that detects if a user (based off his or her User ID) has media in a gallery?

  • Keymaster
    (BuddyDev Team)
    Posts: 24706
    Brajesh Singh on #5076

    Hi Brian,
    Thank you.
    There is a function that will allow you to do it

    
    
    $ids = mpp_get_gallery_ids( array( 'component'=> 'members', 'component_id'=> bp_loggedin_user_id() ) );
    
    $total = count( $ids );
    

    Please do note that I do not recommend multiple usage of it for counting purpose. It is not efficient for multiple usage. In upcoming release we will store the total gallery/media count in the user meta to make it faster.

    Thank you
    Brajesh

  • Participant
    Level: Enlightened
    Posts: 31
    Brian on #5098

    Excellent Brajesh, Thank you very much. Works great!

  • Keymaster
    (BuddyDev Team)
    Posts: 24706
    Brajesh Singh on #5099

    Thank you. Marking it as resolved.

The topic ‘ [Resolved] Detect if user has media in gallery?’ is closed to new replies.

This topic is: resolved