Skip to:
Content
Pages
Categories
Search
Top
Bottom

Limit the length of members latest update in members loop


  • mfalk75
    Participant

    @mfalk75

    Hi, I want to limit the length of the status update that is listed on the members directory page where there are many members listed. I tried replacing <?php bp_member_latest_update() ?> with <?php bp_member_latest_update(‘length=10’) ?> but it didn’t work. Could someone help me out with this 🙂

    Do I need to add something to my functions.php since I’m using a child theme maybe?

Viewing 7 replies - 1 through 7 (of 7 total)

  • shanebp
    Moderator

    @shanebp

    Try:

    <?php 
    $args = array( 'length' => 100 ); 
    bp_member_latest_update( $args );
    ?>
    

    mfalk75
    Participant

    @mfalk75

    Thank you for trying to help. Nope, it does show the update but it’s not shortened at all. Any other ideas?

    Thanks,
    Michael


    shanebp
    Moderator

    @shanebp

    It works here.
    You need to put it in a template overload of this file:
    buddypress\bp-templates\bp-legacy\buddypress\members\members-loop.php

    Replace the update code with this:
    <span class="update"><?php $args = array( 'length' => 50 ); bp_member_latest_update( $args ); ?></span>


    mfalk75
    Participant

    @mfalk75

    hmm, thanks, I don’t get it either. I am editing the file in my child theme at this location: mysite.com/buddypress/members/members-loop.php It’s definitely editing the website as if I delete this part then the last update from a member does not appear. Your code makes the status update appear but it just don’t limit it. I even tried changing 50 to 10 and still long updates. Thanks for your help. Not sure what to do now.


    danbp
    Participant

    @danbp

    Hi @mfalk75,

    try this snippet – in bp-custom.php or child’s functions.php

    function bpfr_truncate_latest_update( $update_content ) {
    	
    	if( 150 < strlen( $update_content ) ) {
    		$update_content = str_replace( '[&hellip;]', '', $update_content );
    		return trim( substr( $update_content, 0, 10 ) ). ' [&hellip;]';
    	}
    	else
    		return $update_content;
    }
    add_filter( 'bp_get_activity_latest_update_excerpt', 'bpfr_truncate_latest_update' );

    Tsted as OK with BP 2.5.2


    mfalk75
    Participant

    @mfalk75

    @danbp do I have to call this a different way in my members-loop.php?


    danbp
    Participant

    @danbp

    There is no need to modify the member loop. You just have to add the function into one of the file i mentionned.

    By doing this with bp-custom.php, you don’t need to alter your curent theme and by the way, it will also work in case you use another theme.

Viewing 7 replies - 1 through 7 (of 7 total)
  • You must be logged in to reply to this topic.
Skip to toolbar