Skip to content

Instantly share code, notes, and snippets.

@nikitasinelnikov
Last active December 15, 2020 14:32
Show Gist options
  • Save nikitasinelnikov/8f83624316459d8b0895cdee14319409 to your computer and use it in GitHub Desktop.
Save nikitasinelnikov/8f83624316459d8b0895cdee14319409 to your computer and use it in GitHub Desktop.
ForumWP: How to extends the topic data
function fmwp_topic_data_custom( $topic_args, $topic ) {
$author = get_userdata( $topic->post_author );
$topic_args['author_username'] = $author->user_login;
if ( ! empty( $topic_args['people'] ) ) {
foreach ( $topic_args['people'] as $people ) {
$user = get_userdata( $people['id'] );
if ( $topic->post_author == $people['id'] ) {
$people['avatar']['title'] = sprintf( __( 'Created by %s', 'forumwp' ), $user->user_login );
} else {
$people['avatar']['title'] = sprintf( __( 'Last reply by %s', 'forumwp' ), $user->user_login );
}
}
}
$topic_args['people'] = $people;
return $topic_args;
}
add_filter( 'fmwp_ajax_response_topic_args', 'fmwp_topic_data_custom', 10, 2 )
Please use {{{<?php echo $item; ?>.author_username}}} to show the custom data
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment