06/22/2016 at 8:58 am
#380314
Keymaster
@ ottomek
re: What would the snippet be to create this text field that only the WP admin could change but it would be read-only/displayed with each Members Profile Directory area.
The following snippet should do the trick.
// Register the metabox and field.
add_action( 'cn_metabox', 'cn_register_custom_metabox_and_date_field' );
function cn_register_custom_metabox_and_date_field() {
$atts = array(
'title' => 'Expiration Date', // Change this to a name which applies to your project.
'id' => 'expiration_date_metabox', // Change this so it is unique to you project.
'context' => 'normal',
'priority' => 'core',
'fields' => array(
array(
'name' => 'Date', // Change this field name to something which applies to you project.
'show_label' => TRUE, // Whether or not to display the 'name'. Changing it to false will suppress the name.
'id' => 'expiration_date', // Change this so it is unique to you project. Each field id MUST be unique.
'type' => 'datepicker', // This is the field type being added.
),
),
);
if ( is_admin() && current_user_can( 'manage_options' ) ) cnMetaboxAPI::add( $atts );
}
Hope that helps!
