BuddyDev

Search

[Resolved] Hide Logged In User Member Card

  • Participant
    Level: Enlightened
    Posts: 31
    Steven May on #31468

    On the members page the first card (member) shows is the current logged in user. Do you have aplugin that hides the card of the current logged in user? I dont see a reason to show the logged in users card in the member directory, why would they need to see themeslves?

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

    Hi Steven,

    Thank you for the question.

    Please use the following code in your bp-custom.php

    
    
    /**
     * Exclude Logged Users from BuddyPress Members List.
     *
     * @param array $args args.
     *
     * @return array
     */
    function buddydev_exclude_logged_user( $args ) {
    	// do not exclude if not logged in or in admin.
    	if ( ! is_user_logged_in() || ( is_admin() && ! defined( 'DOING_AJAX' ) ) ) {
    		return $args;
    	}
    
    	$excluded = isset( $args['exclude'] ) ? $args['exclude'] : array();
    
    	if ( ! is_array( $excluded ) ) {
    		$excluded = explode( ',', $excluded );
    	}
    
    	$excluded[]      = get_current_user_id();
    	$args['exclude'] = $excluded;
    
    	return $args;
    }
    
    add_filter( 'bp_after_has_members_parse_args', 'buddydev_exclude_logged_user' );
    
    

    Regards
    Brajesh

  • Participant
    Level: Enlightened
    Posts: 31
    Steven May on #31491

    That causes a critical error and crashes the site. 🙁

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

    Hi Steven,
    I am sorry for the inconvenience.

    Did you put it in your bp-custom.php.

    if yes, did that file started with
    <?php
    tag.

    If possible, Please share the complete code from that file on pastebin.com and link me.

    Regards
    Brajesh

  • Participant
    Level: Enlightened
    Posts: 31
    Steven May on #31500

    I apologize, under further testing I miust have missind some of the syntax on the first go around. Ity works fine now. Thank you. 🙂

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

    No issues.

    You are welcome 🙂

The topic ‘ [Resolved] Hide Logged In User Member Card’ is closed to new replies.

This topic is: resolved