BuddyDev

Search

[Resolved] Limit Characters in BuddyPress Activity Post

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

    Will any of your plugins allow for a setting that limits the number of characters in a BuddyPress Activity Post and add a “Read More” button/lin after it?

  • Keymaster
    (BuddyDev Team)
    Posts: 24623
    Brajesh Singh on #33544

    Hi Steven,
    Thank you for the question.

    I am assuming you are looking to change thee excerpt length in the activity stream(activity posts list)?

    It is simple doable by 2-4 lines of code without any plugin. We are also including it in one of our upcoming plugins for a no-code solution.

    Please confirm me if this is the case and I will post the code.

    Regards
    Brajesh

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

    Yes thats exactly what I am loking to do. 🙂

  • Keymaster
    (BuddyDev Team)
    Posts: 24623
    Brajesh Singh on #33561

    Sure,
    Here you go.

    
    
    /**
     * Changes length of activity excerpt.
     *
     * @param int $length_in_chars number of character for the excerpt.
     *
     * @return int
     */
    function buddydev_custom_activity_excerpt_length( $length_in_chars ) {
    	$length_in_chars = 20;// change it to as many characters as you want.
    
    	return $length_in_chars;
    }
    
    add_filter( 'bp_activity_excerpt_length', 'buddydev_custom_activity_excerpt_length', 100 );
    

    Please feel free to change the number of characters.

    Regards
    Brajesh

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

    That caused a crtical error and crashed the site. 🙁

  • Keymaster
    Level: Yogi
    (BuddyDev Team)
    Posts: 3115
    Ravi on #33570

    Hello Steven,

    Sorry for the inconvenience. Please try after rename this function. As there might be chance function name conflicting causing fatal error. If issue still persists post be the error you are getting with debug on.

    Regards
    Ravi

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

    Im sorry I dont understand rename this function?

  • Keymaster
    Level: Yogi
    (BuddyDev Team)
    Posts: 3115
    Ravi on #33572

    Hello Steven,

    Please ignore my last message. Please let me know have you copied code direct from email?. If yes please copy the code forum and then give it a shot. If issue still persists, Please share your whole “bp-custom.php” file code through pastebin.

    Regards
    Ravi

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

    That fixed it, thank you.

  • Keymaster
    (BuddyDev Team)
    Posts: 24623
    Brajesh Singh on #33574

    Hi @ravisharma,
    Thank you for the support here.

    Thank you for confirming Steven.

    Regards
    Brajesh

The topic ‘ [Resolved] Limit Characters in BuddyPress Activity Post’ is closed to new replies.

This topic is: resolved