CMB2-Snippet-Library
CMB2-Snippet-Library copied to clipboard
The form is as follows:
I want to edit the Custom Post Type in three ends, but I don't know how to do it. Only codes have been shared here. Is there a case study?
Not quite sure what you're asking here. You want your metabox configuration to show up for 3 different post types? You can pass an array for the object_types parameter and specify multiple things.
Otherwise, I'd need more information to help you.
<div class="my-2 col-xs-6 p-0">
<label class="text-muted">Resim</label>
<div id="user-profile-image" class="dropzone needsclick">
<div class="dz-message needsclick text-muted">
Resim Yükle
</div>
</div>
<div id="dropzone-preview-template" class="d-none plan-image-template">
<div class="dz-preview dz-file-preview">
<input class="mdc-text-field__input" name="danisman-avatar" id="danisman-avatar" value="<?php the_author_meta( 'menkul_user_avatar', $user_ID ); ?>">
<div class="dz-image"><img src="<?php the_author_meta( 'menkul_user_avatar', $user_ID ); ?>" data-dz-thumbnail="<?php the_author_meta( 'menkul_user_avatar', $user_ID ); ?>" alt="prop-image"></div>
<div class="dz-details">
<div class="dz-size"><span data-dz-size="100 KB"></span></div>
<div class="dz-filename"><span data-dz-name="avatar"></span></div>
</div>
<div class="dz-progress"><span class="dz-upload" data-dz-uploadprogress="<?php the_author_meta( 'menkul_user_avatar', $user_ID ); ?>"></span></div>
<div class="dz-error-message"><span data-dz-errormessage="Resim Yüklenemedi!"></span></div>
<div class="dz-success-mark">
<i class="material-icons mat-icon-xlg">check</i>
</div>
<div class="dz-error-mark">
<i class="material-icons mat-icon-xlg">cancel</i>
</div>
</div>
</div>
</div> ```
I want to add a file to this form, but it doesn't load.
If I'm not mistaken, that output is using https://www.dropzonejs.com/ or at least something really really similar.
That said, I'm not aware of any CMB2 extension that builds off of Dropzone.js so I guess I'm not quite sure how CMB2 plays a part in this.
@tw2113
Firstly, thank you for your reply. I'm trying to edit a publication, but it's really troubled. There are sample codes in the cmb2 library, but I don't understand how to integrate it into my theme.
If you can point out which ones you're referring to, I could probably help provide some guidance on how to get them loaded.
the code below is working on my frontend profile page edit code.
`< ?php error_reporting(0); if ( is_user_logged_in() ) : {
$user_ID = get_current_user_id();
$user_info = get_userdata($user_ID);
/* Personal Info */
$dwebsite = get_user_meta( $user_ID, 'user_url', true );
$dhakkimda = $user_info->description;
$dkullaniciadi = $user_info->user_login;
$dadi = $user_info->first_name;
$dsoyadi = $user_info->last_name;
$deposta = $user_info->user_email;
if(isset($_POST['update_user_info']))
{
do_action('edit_user_profile_update', $user_ID);
if ( !empty($_POST['current_pass']) && !empty($_POST['pass1'] ) && !empty( $_POST['pass2'] ) ) {
if ( !wp_check_password( $_POST['current_pass'], $user_info->user_pass, $user_ID) ) {
$error = 'Mevcut şifreniz eşleşmiyor. Lütfen tekrar deneyiniz';
} elseif ( $_POST['pass1'] != $_POST['pass2'] ) {
$error = 'Şifreler eşleşmiyor. Lütfen tekrar deneyiniz.';
} elseif ( strlen($_POST['pass1']) < 4 ) {
$error = 'Şifre çok kısa';
} elseif ( false !== strpos( wp_unslash($_POST['pass1']), "\\" ) ) {
$error = 'Parola "\\" (ters eğik çizgi) karakterini içeremez.';
} else {
$error = wp_update_user( array( 'ID' => $user_ID, 'user_pass' => esc_attr( $_POST['pass1'] ) ) );
if ( !is_int($error) ) {
$error = 'Profiliniz güncellenirken bir hata oluştu. Lütfen tekrar deneyiniz.';
} else {
$error = false;
}
}
echo "<strong>$error</strong>";
}
$userdata = wp_update_user( array( 'ID' => $user_ID, 'first_name' => $_POST['dadi'], 'last_name' => $_POST['dsoyadi'], 'user_email' => esc_attr( $_POST['deposta']), 'description' => esc_attr( $_POST['dhakkimda']), 'user_url' => esc_attr( $_POST['dwebsite'])));
/*** Kullanıcı Metabox Kaydetme Başlangıç ***/
if ( !empty( $_POST['danisman_avatar'] ) ) {
update_user_meta( $user_ID, 'menkul_user_avatar', esc_attr( $_POST['danisman_avatar'] ) );
}
if ( !empty( $_POST['danisman_facebook'] ) ) {
update_user_meta( $user_ID, 'menkul_user_facebookurl', esc_attr( $_POST['danisman_facebook'] ) );
}
if ( !empty( $_POST['danisman_twitter'] ) ) {
update_user_meta( $user_ID, 'menkul_user_twitterurl', esc_attr( $_POST['danisman_twitter'] ) );
}
if ( !empty( $_POST['danisman_instagram'] ) ) {
update_user_meta( $user_ID, 'menkul_user_instagramurl', esc_attr( $_POST['danisman_instagram'] ) );
}
if ( !empty( $_POST['danisman_linkedin'] ) ) {
update_user_meta( $user_ID, 'menkul_user_linkedinurl', esc_attr( $_POST['danisman_linkedin'] ) );
}
if ( !empty( $_POST['danisman_cep_tel'] ) ) {
update_user_meta( $user_ID, 'menkul_user_danismanceptelefonnumarasi', esc_attr( $_POST['danisman_cep_tel'] ) );
}
if ( !empty( $_POST['danisman_sabit_tel'] ) ) {
update_user_meta( $user_ID, 'menkul_user_danismansabittelefonnumarasi', esc_attr( $_POST['danisman_sabit_tel'] ) );
}
/*** Kullanıcı Metabox Kaydetme Bitiş***/
if ( is_wp_error( $userdata ) ) {
echo 'Profil Güncellenemedi!';
} else {
echo '<strong>Profil Güncellendi</strong>';
}
}
} ? >`
sample usage is as follows. I created a custom file meta box for the user. I just couldn't add the user picture.
< div class="mdc-text-field mdc-text-field--outlined w-100 custom-field my-2" >
< input class="mdc-text-field__input" name="dadi" value="< ?php the_author_meta('first_name', $user_ID); ? >">
<div class="mdc-notched-outline">
<div class="mdc-notched-outline__leading"></ div >
<div class="mdc-notched-outline__notch">
<label class="mdc-floating-label">Adı</label>
</div>
< div class="mdc-notched-outline__trailing" >< /div >
< /div >
< /div >
I am not seeing anything related to CMB2 here.
Backend meta boxes were made with cmb2.