在 bbPress 里實現 “帖子簽名” 功能

在您的主題的 “functions.php” 文件里粘貼以下代碼:

function bbp_reply_content_append_user_signature( $content = '', $reply_id = 0, $args = array() ) {
	// Default arguments
	$defaults = array(
		'separator' => '<hr />',
		'before'    => '<div class="bbp-signature">',
		'after'     => '</div>'
	);
	$r = wp_parse_args( $args, $defaults );
	extract( $r );

	// Verify topic id, get author id, and potential signature
	$reply_id  = bbp_get_reply_id       ( $reply_id );
	$user_id   = bbp_get_reply_author_id( $reply_id );
	$signature = xprofile_get_field_data( 'Signature', $user_id );

	// If signature exists, adjust the content accordingly
	if ( !empty( $signature ))
		$content = $content . $separator . $before . $signature . $after;

	return apply_filters( 'bbp_reply_content_append_signature', $content, $reply_id, $separator );
}

add_filter( 'bbp_get_reply_content', 'bbp_reply_content_append_user_signature', 1, 2 );
文章沒看懂?代碼不會用?需要幫助您可以去論壇提問自助服務台

作者Geticer

WordPress的忠實用戶,喜歡講述與BuddyPress和bbPress等有關的故事。 同時也是一位Minecraft玩家……