Skip to:
Content
Pages
Categories
Search
Top
Bottom

Omit time stamps from Activity/feed so only date stamps show


  • PJ
    Participant

    @pjnu

    Is it possible to omit time stamps from a Buddypress install so that users only see the date submitted? I have an install where users are active in the site, but at late hours of the night/morning. They’ve asked for timestamps to be omitted the feed so they can focus on collaborating more, not worrying about if others will see that they’re night owls. Thanks.

Viewing 6 replies - 1 through 6 (of 6 total)
  • Looking at the activity entry file that time stamp is part of the bp_activity_action() template tag, looking that up in core bp-activity-templatetags.php and it shows bp_activity_time_since applied to $content for that template tag.

    A quick and possibly incorrect attempt to remove the time stamp:

    function remove_activity_timestamp() {
    $content = '';
    }
    add_filter('bp_activity_time_since', 'remove_activity_timestamp');

    This works but I feel it isn’t really the best approach so would prefer one of the more experienced chaps to advise if a better or correct approach exits.


    Roger Coathup
    Participant

    @rogercoathup

    @pjnu – unfortunately those “time since” messages are embedded quite deep in the core template tags used by the default theme, and are not the most obvious to remove / change.

    It can be done however.

    The time since text is inserted by a routine called bp_insert_activity_meta() that’s called from the tags the default template uses: bp_activity_action() and bp_activity_content_body().

    There’s no easy way to filter those tags to alter the time presentation [EDIT: perhaps there is – see other comments], so the easiest route is to modify your theme taking out the calls to bp_activity_action() and bp_activity_content_body(), and replacing them with calls to get the parts of the message individually:

    e.g. you can call bp_get_activity_date_recorded() to get the date as a datetime stamp which you can then format with the PHP date() function to display as you want it.

    These template tags are all declared in bp-activity-templatetags.php

    There’s no straight template tag to get the activity_action without the activity_meta (and timestamp) being added – so, we write our own function for that in bp-custom.php and call it from our theme:

    function my_activity_action() {
    global $activities_template;
    
    return ($activities_template->activity->action);
    
    }
    

    You could do something similar for activity_content_body as well.

    Here’s a snippet of what a modified activity/entry.php looks like in one of our themes:

    
    <div class="activity-header">
    
    <p class="metadata">
    <?php if (has_delete_permissions()) {
    echo bp_get_activity_delete_link();
    } ?>
    
    </div>

    I hope that makes sense!


    Roger Coathup
    Participant

    @rogercoathup

    @pjnu

    looking at the filter suggested by @hnla – It looks like you could make that work as well. Rather than setting the content to ” “, you would set it to the date submitted (which I think you are still wanting to display).


    PJ
    Participant

    @pjnu

    Thank you very much @hnla and @rogercoathup


    Ehegwer
    Participant

    @ehegwer

    Still works like a charm for me with
    Version 1.2.7
    WordPress 3.0.3


    angslycke
    Participant

    @angslycke

    Hi!

    Is this solution still working in BuddyPress 1.5 and above? Would like to make the timestamps cleaner by removing minutes when 1 hour has passed and removing hours when 24 hors have passed. Thanks!

Viewing 6 replies - 1 through 6 (of 6 total)
  • The topic ‘Omit time stamps from Activity/feed so only date stamps show’ is closed to new replies.
Skip to toolbar