Last active
December 15, 2020 14:32
-
-
Save nikitasinelnikov/8f83624316459d8b0895cdee14319409 to your computer and use it in GitHub Desktop.
ForumWP: How to extends the topic data
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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 ) |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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