Skip to:
Content
Pages
Categories
Search
Top
Bottom

Changing Activity Stream Time & Date

  • Avatar of mgkoller
    mgkoller
    Participant

    @mgkoller

    Hello, I’m running WordPress 3.4.1. and Buddypress 1.5.6
    I would like to change the Activity stream updates from “right now” , “2 hours, 22 minutes ago” , etc
    to the exact time and date like “07/03/2012 at 12:58 PM”

    Is there a plugin for this? If not
    I’m comfortable with PHP but don’t know were to edit this
    (activity/activity-loop.php) ?

    Thanks and sorry if this is a duplicate post…

    Edit
    Here’s what I’m looking to change (in red)

Viewing 9 replies - 1 through 9 (of 9 total)
  • Avatar of mgkoller
    mgkoller
    Participant

    @mgkoller

    Ok, does anybody know were the activity stream editor is located? Is it activity/activity-loop.php? I’m having trouble finding the correct php line to edit.

    Avatar of Roger Coathup
    Roger Coathup
    Participant

    @rogercoathup

    Take a look at the bp_insert_activity_meta() function – you’ll need to work with the filters in there to modify the date output.

    It’s called indirectly from entry.php in your activity folder, and is responsible for formatting the date.

    It would be a lot easier if was formatted in the template files, but unfortunately it is hard coded in this core function – so working with the filters is your best option.

    Avatar of mgkoller
    mgkoller
    Participant

    @mgkoller

    Thanks so much for responding. I’m having trouble locating this “bp_insert_activity_meta()” function . I can’t find it in entry.php or activity/index.php or anywhere else.

    Or is this a hidden file that I can only access from the server?
    If you could tell me which php file its hiding in it would be much help.

    Thanks!

    Avatar of mgkoller
    mgkoller
    Participant

    @mgkoller

    I think I found it, Its in bp-activity > bp-activity-template.php > starts line 1187 > bp_activity_time_since’
    Thanks @rogercoathup for bp_insert_activity_meta() function hint

    *Update*
    bp_core_time_since( $activities_template->activity->date_recorded ) date_recorded would be the post date
    so it looks like I need to make a new function that uses the regular PHP time function to display the time style

    Avatar of serbelieber
    serbelieber
    Member

    @serbelieber

    Hi mgkoller
    if you’ve solved, you can tell me how?

    Thanks!

    Avatar of Roger Coathup
    Roger Coathup
    Participant

    @rogercoathup

    Don’t change the function.. As I said originally, use the filters it provides to modify the display.
    If you are not familiar with WordPress filters and actions have a Google in the WP docs

    Avatar of mgkoller
    mgkoller
    Participant

    @mgkoller

    I haven’t solved the problem yet, Here’s were I’m looking http://codex.wordpress.org/Function_Reference/add_filter

    Here’s were I think the filter needs to be added?

    `
    * @uses bp_insert_activity_meta()
    * @uses apply_filters_ref_array() To call the ‘bp_get_activity_action’ hook
    *
    * @return string The activity action
    */
    function bp_get_activity_action() {
    global $activities_template;

    $action = $activities_template->activity->action;
    $action = apply_filters_ref_array( ‘bp_get_activity_action_pre_meta’, array( $action, &$activities_template->activity ) );

    if ( !empty( $action ) )
    $action = bp_insert_activity_meta( $action );

    return apply_filters_ref_array( ‘bp_get_activity_action’, array( $action, &$activities_template->activity ) );
    }
    `

    Avatar of Roger Coathup
    Roger Coathup
    Participant

    @rogercoathup

    You add the filter (and associated hook) in your functions.php file. You don’t modify any of the core files.

    ‘hook’ the filter onto one of those hooks that bp_insert_activity_meta provides – e.g. add_filter( ‘bp_activity_time_since’, ‘my-function’, … );

    Avatar of mgkoller
    mgkoller
    Participant

    @mgkoller

    Getting back to this issue
    `
    You add the filter (and associated hook) in your functions.php file
    `
    I’m using the Frisco theme so here is the functions.php

    Github – https://github.com/davidtcarson/frisco/blob/master/functions.php
    Pastebin – http://pastebin.com/2gyXjCnK

    So I need to ‘hook’ the filter onto one of those hooks that bp_insert_activity_meta provides .
    I’m currently trying to find out were to insert this hook in the Frisco functions.php file
    Here’s the custom hook

    `
    add_filter( ‘bp_activity_time_since’, strftime ($time,’l jS of F Y h:i:s A’,);
    `
    Obviously this function isn’t going to work but I’m trying to get the bigger idea,
    I’m doing this on my Localhost using Mamp so I can just work by trial and error.

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

You must be logged in to reply to this topic.