do_action( 'block_editor_meta_box_hidden_fields', WP_Post $post )

Adds hidden input fields to the meta box save form.


Description

Hook into this action to print <input type="hidden" ... /> fields, which will be POSTed back to the server when meta boxes are saved.


Top ↑

Parameters

$post WP_Post
The post that is being edited.

Top ↑

Source

File: wp-admin/includes/post.php. View all references

do_action( 'block_editor_meta_box_hidden_fields', $post );


Top ↑

Changelog

Changelog
Version Description
5.0.0 Introduced.

Top ↑

User Contributed Notes

  1. Skip to note 1 content
    Contributed by Manzoor Wani

    In save_post hook, to check if the post is published via gutenberg, use this

    add_action( 'block_editor_meta_box_hidden_fields', 'add_gutenberg_hidden_fields', 10, 1 );
    function add_gutenberg_hidden_fields( $post ) {
    
    	echo '<input type="hidden" name="your-field" value="some-value">';
    	echo '<input type="hidden" name="is_gutenberg_post" value="1">';
    }

    then inside save_post callback, use

    if ( isset( $_POST['is_gutenberg_post'] ) ) {
        // came from gutengerg
    }

You must log in before being able to contribute a note or feedback.