Last active
May 12, 2016 12:22
-
-
Save Kudratullah/75c6aeac28b3c5b03478fbf908a617c4 to your computer and use it in GitHub Desktop.
cmb2 user meta object_id issue
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?php | |
//issue: cmb2 metabox form getting wrong object_id for user edit form, so it's can't display the meta values stored in database. | |
//cmb2 veriosn 2.2.1 | |
add_action( 'cmb2_init', 'UserMetabox' ); | |
function UserMetabox(){ | |
$cmb_user_fields = new_cmb2_box( array( | |
'id' => '_user_info', | |
'title' => 'User Extras', | |
'object_types' => array( 'user' ), // Tells CMB2 to use user_meta vs post_meta | |
'show_names' => true, | |
//'new_user_section' => 'add-existing-user', | |
) ); | |
$cmb_user_fields->add_field( array( | |
'name' => 'Avatar',, | |
'desc' => 'Upload Avatar image. if not upload default Avatar will be your Gravatar Avatar', | |
'id' => '_user_avatar', | |
'type' => 'file', | |
'allow' => array('attachment' ), | |
'options' => array( | |
'url' => false, | |
'add_upload_file_text' => 'Add Image' | |
), | |
'preview_size' => array( 150, 150 ), | |
) ); | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment