Skip to content

Instantly share code, notes, and snippets.

@barryhughes
Created January 27, 2019 15:59
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save barryhughes/30bacb98b716ecaa864f0b6eaa7c051c to your computer and use it in GitHub Desktop.
Save barryhughes/30bacb98b716ecaa864f0b6eaa7c051c to your computer and use it in GitHub Desktop.
<?php
function on_forum_post_status_transition( $new_status, $old_status, $post ) {
// If we are not looking at a reply or a topic, bail!
if ( ! bbp_is_topic( $post ) && ! bbp_is_reply( $post ) ) {
return;
}
$forum_id = bbp_get_forum_id( $post );
$author_id = bbp_is_topic( $post )
? bbp_get_topic_author_id( $post )
: bbp_get_reply_author_id( $post );
# You now have the (topic or reply) author ID
# and the forum ID and can do further work
}
add_action( 'transition_post_status', 'on_forum_post_status_transition', 10, 3 );
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment