Skip to:
Content
Pages
Categories
Search
Top
Bottom

not recently active

  • Avatar of Bea107
    Bea107
    Participant

    @bea107

    Hello

    On members profile its says ‘not recently active’ I want to remove this line of information, how do I do this?

    Wordpress 3.9.2
    Twenty Eleven Theme with Buddypress

    Thanks

Viewing 7 replies - 1 through 7 (of 7 total)
  • Avatar of henrywright
    henrywright
    Moderator

    @henrywright

    Hi @bea107

    Check out the Template Hierarchy article which will let you customise the BuddyPress templates.

    Avatar of danbp
    danbp
    Moderator

    @danbp

    Hi @bea107,

    some explanation on how to do this, beside reading the codex.

    The original core function we want to modify:

    /**
     * Format last activity string based on time since date given.
     *
     * @uses bp_core_time_since() This function will return an English
     *       representation of the time elapsed.
     *
     * @param int|string $last_activity_date The date of last activity.
     * @param string $string A sprintf()-able statement of the form '% ago'.
     * @return string $last_active A string of the form '3 years ago'.
     */
    function bp_core_get_last_activity( $last_activity_date, $string ) {
    
    	if ( empty( $last_activity_date ) )
    		$last_active = __( 'Not recently active', 'buddypress' );
    	else
    		$last_active = sprintf( $string, bp_core_time_since( $last_activity_date ) );
    
    	return apply_filters( 'bp_core_get_last_activity', $last_active, $last_activity_date, $string );
    }

    To alter it, we have to create a little function. Here’s the custom function which removes the message string:

    function bea107_core_get_last_activity( $last_activity_date, $string ) {
    		if ( empty( $last_activity_date ) )
    				// we do nothing
    				$last_active = '';
    			else
    				$last_active = sprintf( $string, bp_core_time_since( $last_activity_date ) );
    		}
    add_filter( 'bp_core_get_last_activity', 'bea107_core_get_last_activity' );
    

    If you want to remove the whole filter, you use this

    function bea107_remove_last_activity_filter() {
        remove_filter( 'bp_core_get_last_activity', $last_active, $last_activity_date, $string );
    }
    add_filter( 'bp_core_get_last_activity', 'bea107_remove_last_activity_filter' );

    Both function can be added to your child-theme’s functions.php or bp-custom.php

    Avatar of Bea107
    Bea107
    Participant

    @bea107

    Hello

    To remove all activity for all members I put this filter in my Twenty Eleven Child: Stylesheet (style.css) but it didn’t work?

    Any ideas

    function bp_core_get_last_activity( $last_activity_date, $string ) {
    if ( empty( $last_activity_date ) )
    // we do nothing
    $last_active = ”;
    else
    $last_active = sprintf( $string, bp_core_time_since( $last_activity_date ) );
    }
    add_filter( ‘bp_core_get_last_activity’ );

    Avatar of Hugo
    Hugo
    Moderator

    @hnla

    stylesheets are a client side processed file, you cannot place server side code such as PHP in them. To run code such as that filter you either run it from a plugin, your themes functions.php file or from bp-custom.php located in the plugin folder root (and user created – it doesn’t exist by default)

    Avatar of Bea107
    Bea107
    Participant

    @bea107

    Hello

    Just added code below in themes functions.php file and now getting this message

    Parse error: syntax error, unexpected ‘.’ in /home/wordpres/public_html/wp-content/themes/twentyeleven/functions.php on line 741

    function bp_core_get_last_activity( $last_activity_date, $string ) {
    if ( empty( $last_activity_date ) )
    // we do nothing
    $last_active = ”;
    else
    $last_active = sprintf( $string, bp_core_time_since( $last_activity_date ) );
    }
    add_filter( ‘bp_core_get_last_activity’ );

    Avatar of henrywright
    henrywright
    Moderator

    @henrywright

    Hi @bea107

    Did you copy and paste @danbp‘s code? I haven’t tested it myself but if you have copied his code then it doesn’t look like you’ve copied it properly as some of it is certainly missing. For example, where did this bit in your code snippet come from?

    add_filter( ‘bp_core_get_last_activity’ );

    Avatar of danbp
    danbp
    Moderator

    @danbp

    @bea107,

    In addition to @hnla & @henrywright, you also used a wrong function name !

    Original name is function bp_core_get_last_activity

    Custom name is function bea107_core_get_last_activity.
    This is the function you should use.

    Re-read the codex about function.php and specially the last lines marked It’s important to note

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

You must be logged in to reply to this topic.