Action Hook Field

A- A+

There is an element on the Form Elements called Action Hook. This is a great addition for developers to extend the form as they want. It's a placeholder for creating their own hook where they could bind their functions and generate their own dynamic element.



  • $form_id : (integer) The ID of the form
  • $post_id : NULL or (integer) the ID of the post. When creating a new post, the parameter becomes NULL. When editing a post, you get the edited post ID as the parameter
  • $form_settings : (array) An array of form settings


Here we have added a new action hook field called my_brand_new_hook and saving our field informations in a meta key named your_meta_key. We are adding the field into the form with the your_function_name function and updating the form value with update_my_brand_new_hook

Code Example,

* How to use custom Action/hook inside your post form.
* Add the input field to the form
* Save & update the field on the backend metabox
* @param int $form_id
* @param null|int $post_id
* @param array $form_settings
function render_my_custom_hook( $form_id, $post_id, $form_settings ) {
    $value = '';
    if ( $post_id ) {
        $value = get_post_meta( $post_id, 'your_meta_key', true );
    <div class="wpuf-label">
        <label>Text Field</label>
    <div class="wpuf-fields">
        <input type="text" name="my_custom_text_field" value="<?php echo esc_attr( $value ); ?>">
add_action( 'my_custom_action_hook', 'render_my_custom_hook', 10, 3 );
function update_my_brand_new_hook( $post_id ) {
    if ( isset( $_POST['my_custom_text_field'] ) ) {
        update_post_meta( $post_id, 'your_meta_key', $_POST['my_custom_text_field'] );
add_action( 'wpuf_add_post_after_insert', 'update_my_brand_new_hook' );
add_action( 'wpuf_edit_post_after_update', 'update_my_brand_new_hook' );