Action uncanny-automator-pro

bbp_new_reply_post_extras

Additional Actions (After Save) */ Fires after a new reply is saved in BuddyBoss, allowing custom actions with the reply ID.

add_action( 'bbp_new_reply_post_extras', $callback, 10, 1 );

Description

Fires after a new forum reply has been saved and its associated database entries created. Developers can use this hook to perform actions such as updating custom meta for the reply, sending custom notifications, or integrating with other systems immediately after a reply is posted. It's crucial to note this hook fires *after* core BBPress saving logic.


Usage

add_action( 'bbp_new_reply_post_extras', 'your_function_name', 10, 1 );

Parameters

$reply_id (mixed)

Examples

/**
 * Example function hooked to bbp_new_reply_post_extras.
 * This function demonstrates how to use the hook to perform an action
 * after a new reply has been successfully posted in bbPress.
 * In this example, we'll add a custom meta field to the reply.
 *
 * @param int $reply_id The ID of the newly posted reply.
 */
function my_custom_reply_meta_on_new_reply( $reply_id ) {
	// Ensure the reply ID is valid.
	if ( ! $reply_id || ! is_numeric( $reply_id ) ) {
		return;
	}

	// Add a custom meta field to the reply.
	// This could be used for various purposes, like tracking integrations,
	// logging specific events, or storing custom data related to the reply.
	update_comment_meta( $reply_id, '_my_custom_reply_flag', 'processed' );

	// You could also perform other actions here, such as:
	// - Sending a notification to a different system.
	// - Updating user roles or capabilities based on reply activity.
	// - Triggering a custom status update for the reply.
}

// Add the action hook.
// The priority is set to 10, which is the default.
// The accepted_args is 1, as the hook only passes $reply_id.
add_action( 'bbp_new_reply_post_extras', 'my_custom_reply_meta_on_new_reply', 10, 1 );

Placement

This code should be placed in the functions.php file of your active theme, a custom plugin, or using a code snippets plugin.


Source Code

uncanny-automator-pro/src/integrations/buddyboss/actions/bdb-postatopicreply.php:358
uncanny-automator-pro/src/integrations/bbpress/actions/bb-postatopicreply.php:358

*/
		remove_action( 'bbp_new_reply', 'bbp_notify_topic_subscribers', 11 );

		/** Update counts, etc... */
		do_action( 'bbp_new_reply', $reply_id, $topic_id, $forum_id, $anonymous_data, $reply_author, false, $reply_to );

		/** Additional Actions (After Save) */
		do_action( 'bbp_new_reply_post_extras', $reply_id );

		$this->hydrate_tokens(
			array(
				'REPLY_ID'  => absint( $reply_id ),
				'REPLY_URL' => esc_url( get_the_permalink( $reply_id ) ),
			)
		);


Scroll to Top