Title: updateing database
Last modified: August 22, 2016

---

# updateing database

 *  Resolved [emmaandand](https://wordpress.org/support/users/emmaandand/)
 * (@emmaandand)
 * [11 years, 9 months ago](https://wordpress.org/support/topic/updateing-database/)
 * Hi,
    Im trying to add a function that send an email whenever a post is done. 
   For that i need to know what funtion that puts a new question in the database
   and in what file I can find that function.
 * / EA
 * [https://wordpress.org/plugins/anspress/](https://wordpress.org/plugins/anspress/)

Viewing 1 replies (of 1 total)

 *  Plugin Author [Rahul Aryan](https://wordpress.org/support/users/nerdaryan/)
 * (@nerdaryan)
 * [11 years, 9 months ago](https://wordpress.org/support/topic/updateing-database/#post-5169892)
 * 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('admin@yoursite.com', $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('admin@yoursite.com', $subject, $message );
       	}
       }
       ```
   
 * This above code will notify for new answers

Viewing 1 replies (of 1 total)

The topic ‘updateing database’ is closed to new replies.

 * ![](https://s.w.org/plugins/geopattern-icon/anspress_fde1d3.svg)
 * [AnsPress - Question and answer plugin](https://wordpress.org/plugins/anspress/)
 * [Frequently Asked Questions](https://wordpress.org/plugins/anspress/#faq)
 * [Support Threads](https://wordpress.org/support/plugin/anspress/)
 * [Active Topics](https://wordpress.org/support/plugin/anspress/active/)
 * [Unresolved Topics](https://wordpress.org/support/plugin/anspress/unresolved/)
 * [Reviews](https://wordpress.org/support/plugin/anspress/reviews/)

 * 1 reply
 * 2 participants
 * Last reply from: [Rahul Aryan](https://wordpress.org/support/users/nerdaryan/)
 * Last activity: [11 years, 9 months ago](https://wordpress.org/support/topic/updateing-database/#post-5169892)
 * Status: resolved