Skip to:
Content
Pages
Categories
Search
Top
Bottom

How do you change last active to date created?

  • Avatar of casix
    casix
    Member

    @casix

    Sorry for repeated post. The other one I posted was on the wrong spot.

    I would like to show date created for the groups instead of last active.

    I see the function bp_get_group_last_active() and changed it with bp_get_group_date_created() but still give me the same data as the last active.

    Is there a way to get the date or a plugin or something? I search the forum can find nothing.

    Thanks.

Viewing 1 replies (of 1 total)
  • Avatar of casix
    casix
    Member

    @casix

    Never mind I figured it out. I modified the code bp_get_group_date_created() so it does get the date. For those who want to do the same or if the group for buddypress want to modify the code to do it the same, here is what I did.

    I didn’t want to do lot of code change that way if BP does any updates it would be easy to put the mod back in.

    Note: This mod requires you to modifying the BP core make a back up each file before modifying.

    1st I created a new function in the bp_core_function.php called bp_core_date_since() and I put it above bp_core_time_since() to keep them together.



    function bp_core_date_since($older_date) {

    // array of time period chunks
    $chunks = array(
    array( 60 * 60 * 24 * 365 , __( 'year', 'buddypress' ), __( 'years', 'buddypress' ) ),
    array( 60 * 60 * 24 * 30 , __( 'month', 'buddypress' ), __( 'months', 'buddypress' ) ),
    array( 60 * 60 * 24 * 7, __( 'week', 'buddypress' ), __( 'weeks', 'buddypress' ) ),
    array( 60 * 60 * 24 , __( 'day', 'buddypress' ), __( 'days', 'buddypress' ) ),
    array( 60 * 60 , __( 'hour', 'buddypress' ), __( 'hours', 'buddypress' ) ),
    array( 60 , __( 'minute', 'buddypress' ), __( 'minutes', 'buddypress' ) ),
    array( 1, __( 'second', 'buddypress' ), __( 'seconds', 'buddypress' ) )
    );

    if ( !empty( $older_date ) && !is_numeric( $older_date ) ) {
    $time_chunks = explode( ':', str_replace( ' ', ':', $older_date ) );
    $date_chunks = explode( '-', str_replace( ' ', '-', $older_date ) );
    $older_date = gmmktime( (int)$time_chunks[1], (int)$time_chunks[2], (int)$time_chunks[3], (int)$date_chunks[1], (int)$date_chunks[2], (int)$date_chunks[0] );

    }
    $output = date("F d, Y",$older_date);

    return $output;
    }

    Next I modify the function bp_group_date_created() in the bp_groups_template.php

    rem out the return and created a new return



    return apply_filters( 'bp_get_group_date_created', bp_core_date_since(strtotime($group->date_created)) );

    Now anytime you want to show date created in stead of time since you just replace bp_groups_last_active() to bp_groups_date_created().

    So now instead of showing “active since 1 day, 20 hours”. It shows “Created September 8, 2011″

Viewing 1 replies (of 1 total)

The topic ‘How do you change last active to date created?’ is closed to new replies.