BDB_USERPOSTREPLYFORUM::bbp_insert_reply( $reply_id,  $topic_id,  $forum_id )

Validation function when the trigger action is hit


Parameters Parameters

$reply_id

(Required)

$topic_id

(Required)

$forum_id

(Required)


Source Source

File: src/integrations/buddyboss/triggers/bdb-userpostreplyforum.php

	public function bbp_insert_reply( $reply_id, $topic_id, $forum_id ) {



		$recipes = Automator()->get->recipes_from_trigger_code( $this->trigger_code );

		$conditions = $this->match_condition( $topic_id, $forum_id, $recipes, $this->trigger_meta, $this->trigger_code, 'SUBVALUE' );

		if ( ! $conditions ) {
			return;
		}

		$user_id = get_current_user_id();
		if ( ! empty( $conditions ) ) {
			foreach ( $conditions['recipe_ids'] as $recipe_id => $trigger_id ) {
				if ( ! Automator()->is_recipe_completed( $recipe_id, $user_id ) ) {
					$args = [
						'code'             => $this->trigger_code,
						'meta'             => $this->trigger_meta,
						'recipe_to_match'  => $recipe_id,
						'trigger_to_match' => $trigger_id,
						'post_id'          => $topic_id,
						'user_id'          => $user_id,
					];

					$args = Automator()->maybe_add_trigger_entry( $args, false );
					if ( $args ) {
						foreach ( $args as $result ) {
							if ( true === $result['result'] ) {
								$trigger_meta = [
									'user_id'        => $user_id,
									'trigger_id'     => $result['args']['trigger_id'],
									'trigger_log_id' => $result['args']['get_trigger_id'],
									'run_number'     => $result['args']['run_number'],
								];

								$trigger_meta['meta_key']   = 'BDBTOPICREPLY';
								$trigger_meta['meta_value'] = $reply_id;
								Automator()->insert_trigger_meta( $trigger_meta );

								Automator()->maybe_trigger_complete( $result['args'] );
							}
						}
					}
				}
			}
		}
	}