Skip to:
Content
Pages
Categories
Search
Top
Bottom

Re: How to display when the User Edited His post

@cnorris23

Participant

This would take some code work, because neither bbPress or BuddyPress store this information. You would need to hook into ‘groups_edit_forum_post’ and the use bb_update_postmeta() and bb_get_postmeta() to save/retrieve the information. The following will get you started:

`my_update_forum_post_last_edited( $post_id ) {
global $bp;

do_action( ‘bbpress_init’ );

$post_id = (int) $post_id;

if ( empty( $post_id ) )
return;

bb_update_postmeta( $post_meta, ‘last_edited_date’, bp_core_current_time() );
bb_update_postmeta( $post_meta, ‘last_edited_user’, $bp->loggedin_user->id );
}
add_action( ‘groups_edit_forum_post’, ‘my_update_post_lasted_edited’ );

function my_display_forum_post_last_edited() {
do_action( ‘bbpress_init’ );

$last_edited_user = bb_get_postmeta( bp_get_the_topic_post_id(), ‘last_edited_user’ );
$last_edited_date = bb_get_postmeta( bp_get_the_topic_post_id(), ‘last_edited_date’ );

if ( empty( $last_edited_user ) || empty( $last_edited_date ) )
return;

echo ‘Last edited by ‘ . bp_core_get_user_display_name( $last_edited_user ) . ‘ on ‘ . bp_format_time( $last_edited_date ) . ‘ ‘;
}
add_action( ‘bp_group_forum_post_meta’, ‘my_display_forum_post_last_edited’ );`

Skip to toolbar