Bdb_Tokens::parse_bp_token( $value,  $pieces,  $recipe_id,  $trigger_data,  $user_id,  $replace_args )


Parameters Parameters

$value

(Required)

$pieces

(Required)

$recipe_id

(Required)

$trigger_data

(Required)


Top ↑

Return Return

(mixed)


Source Source

File: src/integrations/buddyboss/tokens/bdb-tokens.php

	public function parse_bp_token( $value, $pieces, $recipe_id, $trigger_data, $user_id, $replace_args ) {
		if ( $pieces ) {
			if ( in_array( 'BDBUSERAVATAR', $pieces ) ) {
				// Get Group id from meta log
				if ( function_exists( 'get_avatar_url' ) ) {
					$value = get_avatar_url( $user_id );
				}
			} elseif ( in_array( 'BDBXPROFILE', $pieces ) ) {

				if ( isset( $pieces[2] ) && ! empty( $pieces[2] ) ) {
					$value = $this->get_xprofile_data( $user_id, $pieces[2] );
				}
			} elseif ( in_array( 'BDBTOPICREPLY', $pieces ) ) {
				$piece = 'BDBTOPIC';

				$recipe_log_id = Automator()->maybe_create_recipe_log_entry( $recipe_id, $user_id )['recipe_log_id'];
				if ( $trigger_data && $recipe_log_id ) {
					foreach ( $trigger_data as $trigger ) {
						if ( key_exists( $piece, $trigger['meta'] ) ) {
							$trigger_id     = $trigger['ID'];
							$trigger_log_id = $replace_args['trigger_log_id'];
							$meta_key       = $pieces[2];
							$meta_value     = Automator()->helpers->recipe->get_form_data_from_trigger_meta( $meta_key, $trigger_id, $trigger_log_id, $user_id );
							if ( ! empty( $meta_value ) ) {
								$content = get_post_field( 'post_content', $meta_value );
								$value   = apply_filters( 'bbp_get_reply_content', $content, $meta_value );
							}
						}
					}
				}
			} elseif ( in_array( 'BDBNEWTOPIC', $pieces ) ) {
				$piece = 'BDBFORUMSTOPIC';

				$recipe_log_id = Automator()->maybe_create_recipe_log_entry( $recipe_id, $user_id )['recipe_log_id'];
				if ( $trigger_data && $recipe_log_id ) {
					foreach ( $trigger_data as $trigger ) {
						if ( key_exists( $piece, $trigger['meta'] ) ) {
							$trigger_id     = $trigger['ID'];
							$trigger_log_id = $replace_args['trigger_log_id'];
							$meta_key       = 'BDBTOPIC';
							$meta_value     = Automator()->helpers->recipe->get_form_data_from_trigger_meta( $meta_key, $trigger_id, $trigger_log_id, $user_id );
							if ( ! empty( $meta_value ) ) {
								if ( 'BDBTOPICID' === $pieces[2] ) {
									$value = $meta_value;
								} elseif ( 'BDBTOPICTITLE' === $pieces[2] ) {
									$title = get_the_title( $meta_value );
									$value = apply_filters( 'bbp_get_topic_title', $title, $meta_value );
								} elseif ( 'BDBTOPICURL' === $pieces[2] ) {
									$topic_permalink = get_permalink( $meta_value );
									$value           = apply_filters( 'bbp_get_topic_permalink', $topic_permalink, $meta_value );
								} elseif ( 'BDBTOPICCONTENT' === $pieces[2] ) {
									$content = get_post_field( 'post_content', $meta_value );
									$value   = apply_filters( 'bbp_get_topic_content', $content, $meta_value );
								}
							}
						}
					}
				}
			} elseif ( in_array( 'BDBUSERACTIVITY', $pieces ) ) {

				if ( $trigger_data ) {
					foreach ( $trigger_data as $trigger ) {
						$trigger_id     = $trigger['ID'];
						$trigger_log_id = $replace_args['trigger_log_id'];
						$meta_key       = $pieces[2];
						$meta_value     = Automator()->helpers->recipe->get_form_data_from_trigger_meta( $meta_key, $trigger_id, $trigger_log_id, $user_id );
						if ( ! empty( $meta_value ) ) {
							$value = $meta_value;
						}
					}
				}
			}
		}

		return $value;
	}