What is the order of firing for these three hooks?
add_filter( 'comments_array', array( $this, 'BuildCommentsArray' ), 10, 2 );
add_action( 'preprocess_comment', array( $this, 'write' ), 10, 1 );
add_action( 'comment_post', array( $this, 'add_meta' ), 10, 1 );
This is what I'm trying to achieve, but I'm getting a loop.
In BuildCommentsArray, posts from a forum are found that have not been written to WordPress. Write the post to a WordPress comment and write to commentmeta.
update_comment_meta( $comment_id, 'origin', 'XenForo');
The preprocess_comment takes a new WordPress comment and writes it to the forum. There is a conditional to look for the 'origin' meta value. If not present then write to the forum.
The comment_post adds meta to the WP comment with post_id and thread_id information.
What's happening is
- the forum post is written to WordPress database.
- the 'origin' meta value is in the WordPress commentmeta
However, a new forum post is created from the WordPress comment despite having the 'origin' conditional.
$origin = get_comment_meta( $comment->comment_ID, 'origin', true );
if ( $origin != 'XenForo') {
// Write to Forum
}
This brings me to the question, is the preprocess_comment hook firing before the comments_array?
In which case, can I influence the firing by changing the 10 in the add_action?
Thank you for pointing to any information to help.