I solved it with the following code:
I went in: /wp-content/plugin/asgaros-forum/includes/forum-content.php
At line 286 there is the code for inserting, in database, the replies (POST). So, I add the following code in PHP. Send an email for each entry of a new post.
The section ” //Inserts a new post. ” became –>
// Inserts a new post.
public function insert_post($topic_id, $forum_id, $text, $author_id = false, $uploads = array()) {
// Set the author ID.
if (!$author_id) {
$author_id = $this->asgarosforum->permissions->currentUserID;
}
// Get the current time.
$date = $this->asgarosforum->current_time();
// Insert the post.
$this->asgarosforum->db->insert($this->asgarosforum->tables->posts, array('text' => $text, 'parent_id' => $topic_id, 'forum_id' => $forum_id, 'date' => $date, 'author_id' => $author_id, 'uploads' => maybe_serialize($uploads)), array('%s', '%d', '%d', '%s', '%d', '%s'));
// Return the ID of the inserted post.
$post_id = $this->asgarosforum->db->insert_id;
// Var email send - CUSTOM
$site_url = get_home_url();
$user_info = get_userdata($author_id);
$user_info_name= $user_info->user_login;
$user_slug = $user_info->user_nicename;
$user_info_link = $site_url.'/forum/profile/'.$user_slug;
$post_id = $this->asgarosforum->db->insert_id;
$link_url = $site_url.'/forum/topic/'.$topic_id.'/?highlight_post='.$post_id.'#postid-'.$post_id;
$body = "<h2> New replies </h2>
<p> <strong> Author </strong> <a href='$user_info_link'>$user_info_name</a>; </p>
<p> <strong> Text: </strong> $text;
<p> <strong> Date: </strong> $date;
<h4> Link: </h4>
<p> <a href='$link_url'>$link_url</a></p>";
$headers = array('Content-Type: text/html; charset=UTF-8');
// Send email - CUSTOM
return wp_mail( "INSERT_YOUR_EMAIL", "YOUR_SUBJECT_HERE", $body, $headers );
}
“INSERT_YOUR_EMAIL” –> you have to insert your email;
“YOUR_SUBJECT_HERE” –> you have to insert the subject of email;
The code will work only if you have set the name of the forum page as “forum” (and permalink “forum”).