Title: entry_saved hook
Last modified: November 27, 2017

---

# entry_saved hook

 *  Resolved [codevelop](https://wordpress.org/support/users/codevelop/)
 * (@codevelop)
 * [8 years, 6 months ago](https://wordpress.org/support/topic/entry_saved-hook/)
 * It’d be great if we could have a hook within entry_saved, so that we can add 
   some more info to the newly created entry.
 * For example, if my form is submitted by a logged-in user, I want to save their
   user ID. I don’t want to create a form field for this, as I’d need hide it and
   make it readonly

Viewing 3 replies - 1 through 3 (of 3 total)

 *  Thread Starter [codevelop](https://wordpress.org/support/users/codevelop/)
 * (@codevelop)
 * [8 years, 6 months ago](https://wordpress.org/support/topic/entry_saved-hook/#post-9726945)
 * Correction, I think it would be best to hook into create_entry (not entry_saved)
 *  Thread Starter [codevelop](https://wordpress.org/support/users/codevelop/)
 * (@codevelop)
 * [8 years, 6 months ago](https://wordpress.org/support/topic/entry_saved-hook/#post-9726962)
 *     ```
       /**
       	 * Create entry when form is submitted
       	 *
       	 * @since 1.0.0
       	 *
       	 */
       	function create_entry( $form ) {
   
       		// Make sure entries should be created
       		if ( ! $form['create_entries'] ) {
       			return;
       		}
   
       		// Create entry post
       		$post_data = array(
       			'post_type' 		=> 'af_entry',
       			'post_status' 		=> 'publish',
       			'post_title'		=> '',
       		);
   
       		$entry_id = wp_insert_post( $post_data );
   
       		if ( ! $entry_id ) {
       			return;
       		}
   
       		// Update post title
       		$updated_title_data = array(
       			'ID' 			=> $entry_id,
       			'post_title' 	=> sprintf( '#%s', $entry_id ),
       		);
   
       		wp_update_post( $updated_title_data );
   
       		// Save general entry info
       		update_post_meta( $entry_id, 'entry_form', $form['key'] );
       		update_post_meta( $entry_id, 'entry_submission_date', date( 'Y-m-d H:i:s' ) );
       		update_post_meta( $entry_id, 'entry_ip_address', $_SERVER['REMOTE_ADDR'] );
   
       		// Transfer all fields to the entry
       		af_save_all_fields( $entry_id );
   
       		// Save generated entry ID to submission object
       		AF()->submission['entry'] = $entry_id;
   
               apply_filters( 'af/form/entry', $entry_id );
               apply_filters( 'af/form/entry/id=' . $form['post_id'], $entry_id );
               apply_filters( 'af/form/entry/key=' . $form['key'], $entry_id );
   
       	}
       ```
   
 *  Plugin Author [fabianlindfors](https://wordpress.org/support/users/fabianlindfors/)
 * (@fabianlindfors)
 * [8 years, 5 months ago](https://wordpress.org/support/topic/entry_saved-hook/#post-9748594)
 * Good idea! I’ll add an action to the upcoming release.
 * Thank you!

Viewing 3 replies - 1 through 3 (of 3 total)

The topic ‘entry_saved hook’ is closed to new replies.

 * ![](https://ps.w.org/advanced-forms/assets/icon-256x256.png?rev=1894254)
 * [Advanced Forms for ACF](https://wordpress.org/plugins/advanced-forms/)
 * [Frequently Asked Questions](https://wordpress.org/plugins/advanced-forms/#faq)
 * [Support Threads](https://wordpress.org/support/plugin/advanced-forms/)
 * [Active Topics](https://wordpress.org/support/plugin/advanced-forms/active/)
 * [Unresolved Topics](https://wordpress.org/support/plugin/advanced-forms/unresolved/)
 * [Reviews](https://wordpress.org/support/plugin/advanced-forms/reviews/)

 * 3 replies
 * 2 participants
 * Last reply from: [fabianlindfors](https://wordpress.org/support/users/fabianlindfors/)
 * Last activity: [8 years, 5 months ago](https://wordpress.org/support/topic/entry_saved-hook/#post-9748594)
 * Status: resolved