hi emmaandand,
Sorry for late replay, I was teribbly busy with AnsPress next version. I was working on realtime updates of questions, answers and comments and that was making me mad, luckily this is solved and now AnsPress have realtime update feature
here is the solution:
add_action( 'after_submitting_question', 'ra_send_ne_q_email' );
function ra_send_ne_q_email( $post_id ) {
// lets check if post is not revision
if ( !wp_is_post_revision( $post_id ) ) {
$post_url = get_permalink( $post_id );
$post = get_post($post_id);
$subject = 'New Question: '.$post->post_title;
$message = $post->post_content;
$message .= "Click here to view\n\n";
//Admin email id
wp_mail('[email protected]', $subject, $message );
}
}
This above function will send email for new questions
add_action( 'after_submitting_answer', 'ra_send_ne_a_email' );
function ra_send_ne_a_email( $post_id ) {
// lets check if post is not revision
if ( !wp_is_post_revision( $post_id ) ) {
$post = get_post($post_id);
$parent = get_post($post->post_parent);
$subject = 'New Answer on - '.$parent->post_title;
$message = $post->post_content;
$message .= "\n\nID)."#".$post->ID. "'>Click here to view\n\n";
//sends email
if($post->post_author != $parent->post_author){
$email = get_the_author_meta( 'user_email', $parent->post_author);
wp_mail($email, $subject, $message );
}
//notify to admin
if($post->post_author != '1')
wp_mail('[email protected]', $subject, $message );
}
}
This above code will notify for new answers