BuddyDev

Search

Replies

  • Keymaster
    Level: Yogi
    (BuddyDev Team)
    Posts: 3115
    This reply has been marked as private.
  • Keymaster
    Level: Yogi
    (BuddyDev Team)
    Posts: 3115
    Ravi on in reply to: [Resolved] Add button in member directory. #45448

    Hello Christian,

    Try the following code:

    
    
    add_action( 'bp_directory_members_actions', function () {
    	$member_id = bp_get_member_user_id();
    
    	if ( ! $member_id || ! bp_is_members_directory() ) {
    		return;
    	}
    
    	$user_domain = bp_core_get_user_domain( $member_id );
    
    	if ( bp_is_active( 'xprofile' ) ) {
    		$profile_link = $user_domain . bp_get_profile_slug();
    
    		echo sprintf( '<div class="generic-button"><a href="%s">%s</a></div>', esc_url( $profile_link ), esc_html__( 'View Profile' ) );
    	}
    
    	echo sprintf( '<div class="generic-button"><a href="%s">%s</a></div>', esc_url( $user_domain ), esc_html__( 'Contact' ) );
    } );
    
    

    Regards
    Ravi

  • Keymaster
    Level: Yogi
    (BuddyDev Team)
    Posts: 3115

    Hello Tosin,

    I am looking at this and will update you soon.

    Regards
    Ravi

  • Keymaster
    Level: Yogi
    (BuddyDev Team)
    Posts: 3115
    Ravi on in reply to: use buddypress function in theme function.php #45445

    Hello Abhist,

    Thank you for posting. BuddyPress does provide a custom file for tweaking BuddyPress functionality i.e. ‘bp-custom.php’ file.

    For more info you can refer to the following URL:
    https://buddydev.com/docs/buddypress-guides/what-is-bp-custom-php/

    Please do let me know what you want to achieve with the code so that I can help you.

    Please do let me know if you still face the issue.

    Regards
    Ravi

  • Keymaster
    Level: Yogi
    (BuddyDev Team)
    Posts: 3115
    Ravi on in reply to: [Resolved] Add button in member directory. #45444

    Hello Christian,

    Thank you for posting. Please let me know which theme and BuddyPress template pack you are using so that I can help.

    Regards
    Ravi

  • Keymaster
    Level: Yogi
    (BuddyDev Team)
    Posts: 3115
    Ravi on in reply to: [Resolved] Create Gallery – Extend entry in activity #45442

    Hello Maurice,

    Thank you for the acknowledgement. Please use the following code with the above code:

    
    
    add_filter( 'bp_get_activity_content_body', function ( $content, $activity ) {
    
    	if ( ! function_exists( 'mediapress' ) || empty( $activity ) || empty( $activity->id ) ) {
    		return $content;
    	}
    
    	$activity_type = bp_activity_get_meta( $activity->id, '_mpp_activity_type', true );
    	$gallery_id    = bp_activity_get_meta( $activity->id, '_mpp_gallery_id', true );
    
    	if ( ! $activity_type || ! $gallery_id || 'create_gallery' != $activity_type ) {
    		return $content;
    	}
    
    	$gallery_permalink = mpp_get_gallery_permalink( $gallery_id );
    
    	$new_content = '';
    	if ( mpp_gallery_has_cover_image( $gallery_id ) ) {
    		$new_content = sprintf(
    			'<a href="%s"><img src="%s" /></a>',
    			esc_url( $gallery_permalink ),
    			esc_url( mpp_get_gallery_cover_src( 'thumbnail', $gallery_id ) )
    		);
    
    		$new_content .= sprintf(
    			'<a href="%s">%s</a>',
    			esc_url( $gallery_permalink ),
    			mpp_get_gallery_title( $gallery_id )
    		);
    	}
    
    	return $new_content ? $new_content : $content;
    }, 10, 2 );
    
    

    Please check and let me know if it works.

    Regards
    Ravi

    • This reply was modified 2 years, 7 months ago by Ravi.
  • Keymaster
    Level: Yogi
    (BuddyDev Team)
    Posts: 3115
    Ravi on in reply to: [Resolved] BuddyPress Member Types in bbPress Forums #45410

    Hello Darbii,

    Thank you for the acknowledgement. I am glad that I could help.

    Regards
    Ravi

  • Keymaster
    Level: Yogi
    (BuddyDev Team)
    Posts: 3115

    Hello Abhist,

    Thank you for posting. But sorry I am not able to understand your requirement. Please help me understand it more clearly.

    Regards
    Ravi

  • Keymaster
    Level: Yogi
    (BuddyDev Team)
    Posts: 3115
    Ravi on in reply to: [Resolved] BuddyPress Member Types in bbPress Forums #45406

    Hello Darbii,

    Thank you for the acknowledgement. It seems your theme uses the topic author role as well. Please try the following code and let me know if it helps or not.

    
    /**
     * Replace author role with member type
     *
     * @param string $author_role Author role.
     * @param array  $r Args.
     *
     * @return string
     */
    function buddydev_bbp_replace_author_role_with_member_type( $author_role, $r ) {
    
    	if ( ! function_exists( 'bp_get_member_type' ) ) {
    		return $author_role;
    	}
    
    	$author_id = 0;
    	if ( ! empty( $r['reply_id'] ) ) {
    		$author_id = bbp_get_reply_author_id( $r['reply_id'] );
    	} elseif ( ! empty( $r['topic_id'] ) ) {
    		$author_id = bbp_get_topic_author_id( $r['topic_id'] );
    	}
    
    	if ( ! $author_id ) {
    		return $author_role;
    	}
    
    	$member_type = bp_get_member_type( $author_id );
    	$member_type = $member_type ? bp_get_member_type_object( $member_type )->labels['singular_name'] : '';
    
    	// Backwards compatibility with old 'class' argument.
    	if ( ! empty( $r['class'] ) ) {
    		$author_role = sprintf( '%1$s<div class="%2$s">%3$s</div>%4$s', $r['before'], esc_attr( $r['class'] ), esc_html( $member_type ), $r['after'] );
    	} else {
    		$author_role = $r['before'] . $member_type . $r['after'];
    	}
    
    	return $author_role;
    }
    
    add_filter( 'bbp_get_reply_author_role', 'buddydev_bbp_replace_author_role_with_member_type', 10, 2 );
    add_filter( 'bbp_get_topic_author_role', 'buddydev_bbp_replace_author_role_with_member_type', 10, 2 );
    
    

    Regards
    Ravi

  • Keymaster
    Level: Yogi
    (BuddyDev Team)
    Posts: 3115
    Ravi on in reply to: Custom notification #45353

    Hi,

    You are welcome.

    I am sorry, I lack the time to assist you further with custom code.

    Please take a look at this page, especially the bottom links to see how to create BuddyPress Notifications.

    https://codex.buddypress.org/administrator-guide/notifications/

    Regards
    Ravi