Fields / Hidden

Read More: Fieldmanager_Hidden

Hidden input fields.

Hidden input fields may not be the most exciting, but can be extremely useful in passing and storing data, especially when working with a JS-driven interface.

  1. Example 1: Basic Hidden Field

    This example is a bit ridiculous, because you'd end up with a visually empty meta box!

    add_action( 'fm_post_post', function() {
    	$fm = new Fieldmanager_Hidden( array(
    		'name' => 'demo-field',
    	) );
    	$fm->add_meta_box( 'Uninteresting Demo', array( 'post' ) );
    } );
  2. Example 2: Setting a Default Value

    Setting the default value in a hidden field is one of the more useful ways to leverage it. In this example, we're setting it to the current user's display name, which we could then leverage to create some personalized feature.

    add_action( 'fm_post_post', function() {
    	$fm = new Fieldmanager_Hidden( array(
    		'name' => 'current-user',
    		'default_value' => get_the_author_meta( 'display_name', get_current_user_id() ),
    	) );
    	$fm->add_meta_box( 'Default Value Demo', array( 'post' ) );
    } );