Guest User

Untitled

a guest
Jun 22nd, 2015
277
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
PHP 1.24 KB | None | 0 0
  1. add_action( 'cmb2_init', 'yourprefix_register_about_page_metabox' );
  2.  
  3. /**
  4.  * Hook in and add a metabox that only appears on the 'About' page
  5.  */
  6. function yourprefix_register_about_page_metabox() {
  7.         // Start with an underscore to hide fields from custom fields list
  8.         $prefix = 'rio_members';
  9.         /**
  10.          * Metabox to be displayed on a single page ID
  11.          */
  12.         $cmb_about_page = new_cmb2_box( array(
  13.                 'id'           => $prefix . 'metabox',
  14.                 'title'        => __( 'Members Signup & Expiration', 'cmb2' ),
  15.                 'object_types' => array( 'user', ), // Post type
  16.                 'context'      => 'normal',
  17.                 'priority'     => 'high',
  18.                 'show_names'   => true, // Show field names on the left
  19.  
  20.         ) );
  21.  
  22.  
  23. if( current_user_can('read') ) {
  24.     // stuff here for admins or editors
  25.  
  26.  
  27.     $cmb_about_page->add_field( array(
  28.                 'name' => __( 'Members Signup & Expiration date', 'cmb2' ),
  29.                 'desc' => __( 'Set expiration date of membership', 'cmb2' ),
  30.                 'id'   => $prefix . 'datetime_expiration',
  31.                 'type' => 'text_date_timestamp',
  32.     ) );
  33.  
  34. echo $prefix . 'datetime_expiration';
  35.  
  36. }
  37.  
  38. }
Advertisement
Add Comment
Please, Sign In to add comment