WPF_TOPIC_ADDED_TOKENS::user_replies_to_topic( $value, $pieces, $recipe_id, $trigger_data, $user_id, $replace_args )
Contents
Parameters Parameters
- $value
-
(Required)
- $pieces
-
(Required)
- $recipe_id
-
(Required)
- $trigger_data
-
(Required)
Return Return
(mixed)
Source Source
File: src/integrations/wpforo/tokens/wpf-topic-added-tokens.php
public function user_replies_to_topic( $value, $pieces, $recipe_id, $trigger_data, $user_id, $replace_args ) { $tokens = [ 'WPFORO_FORUM', 'WPFORO_FORUM_ID', 'WPFORO_FORUM_URL', 'WPFORO_TOPIC', 'WPFORO_TOPIC_ID', 'WPFORO_TOPIC_URL', 'WPFORO_TOPIC_CONTENT', ]; if ( $pieces && isset( $pieces[2] ) ) { $meta_field = $pieces[2]; if ( ! empty( $meta_field ) && in_array( $meta_field, $tokens ) ) { if ( $trigger_data ) { foreach ( $trigger_data as $trigger ) { $trigger_id = $trigger['ID']; $trigger_log_id = $replace_args['trigger_log_id']; $run_number = $replace_args['run_number']; $user_id = $replace_args['user_id']; $forum_id = absint( Automator()->get->get_trigger_log_meta( 'WPFORO_TOPIC_FORUM_ID', $trigger_id, $trigger_log_id, $run_number, $user_id ) ); $forum = array(); if ( $forum_id ) { $forum = WPF()->forum->get_forum( $forum_id ); } $topic_id = absint( Automator()->get->get_trigger_log_meta( 'WPFORO_TOPIC_ID', $trigger_id, $trigger_log_id, $run_number, $user_id ) ); $topic = array(); if ( $topic_id ) { $topic = WPF()->topic->get_topic( $topic_id ); } switch ( $meta_field ) { case 'WPFORO_FORUM': if ( ! empty( $forum ) && isset( $forum['title'] ) ) { $value = $forum['title']; } break; case 'WPFORO_FORUM_ID': if ( $forum_id ) { $value = $forum_id; } break; case 'WPFORO_FORUM_URL': if ( ! empty( $forum ) && isset( $forum['slug'] ) ) { $value = wpforo_home_url( utf8_uri_encode( $forum['slug'] ) ); } break; case 'WPFORO_TOPIC': if ( ! empty( $topic ) && isset( $topic['title'] ) ) { $value = $topic['title']; } break; case 'WPFORO_TOPIC_ID': if ( $topic_id ) { $value = $topic_id; } break; case 'WPFORO_TOPIC_URL': if ( ! empty( $forum ) && isset( $forum['slug'] ) ) { if ( ! empty( $topic ) && isset( $topic['slug'] ) ) { $value = wpforo_home_url( $forum['slug'] . '/' . $topic['slug'] ); } } break; case 'WPFORO_TOPIC_CONTENT': if ( ! empty( $topic ) && isset( $topic['first_postid'] ) ) { $first_post = wpforo_post( $topic['first_postid'] ); if ( ! empty( $first_post ) && isset( $first_post['body'] ) ) { $value = $first_post['body']; } } break; } } } } } return $value; }
Expand full source code Collapse full source code View on Github