Support Forum
Hello,
I took your image field demo and put it in a group. The image upload does not work anymore.
Can you fix this ?
Regards,
$meta_boxes[] = array( 'post_types' => array( 'post' ), 'title' => esc_html__( 'Image Upload Demo', 'your-prefix' ), 'fields' => array( array( 'name' => '', 'id' => 'test_group', 'type' => 'group', 'fields' => array( array( 'id' => 'image', 'name' => esc_html__( 'Image', 'your-prefix' ), 'type' => 'image', 'force_delete' => false, 'max_file_uploads' => 2, ), ), ), ), );
This fix is pretty important for me. If you can fix it quickly you would be awesome.
Hi there,
Can you use the image_advanced
field before we can solve this problem?
Update: Oh. Sorry. I have just read your topic about uploading image in frontend. We are checking this problem. Please wait.
Hello,
I have a problem with both configuration (image or image_upload), but you saw that 🙂
https://support.metabox.io/topic/image-upload-does-not-work-with-mb-frontend-submission/
Thank you for your support,
Hi,
Can you give me your email? I'll send you the fixed code. We still have some works with Meta Box Group so we will update it later.
Please make sure that you are using Meta Box Group 1.2.10 before use fixed code.
UPDATE: We have just released Meta Box Group 1.2.11. Please update it.
Thanks.
Hi,
Will try Meta Box Group 1.2.11.
Thank you,
Hello,
I tested Meta Box Group 1.2.11 today.
That does not work, and the problems are multiples.
1. If I select an image, then save the post. If i save the post again (even without touching anything), the image is no more linked to the field (and stays in the media library as an orphan)
See https://screencast-o-matic.com/watch/cbjbbpl77B
Behaviour is the same in front or back
2. If the group is clonable (and only 1 file allowed per field), the behaviour is weird. All medias seems to go in the first group instead of one per group after save.
See https://screencast-o-matic.com/watch/cbjbbGl77W
After a second save, all images are gone (see 1)
Regards,
Hi,
I got the problem. We are fixing it ASAP.
Thank you.
Ok,
Keep me up to date, please
Thank you
Hello,
Do you have any news ? I'm taking a quick fix if you have one.
My client is supposed to begin to use the forms today.
Regards,
Hi there,
Can you give me your email address? I will give you a quick fix version. This version works if the image field is in level 1 of group (like your case).
Thank you.
Hi there,
Sorry about this. There are some problems so we can't send you the hotfix. You can use image_advanced field and add upload_files
capability for users. The code below add that cap for subscriber:
/**
* Allow the media uploader work on specific pages
*/
function mb_allow_contributor_uploads() {
if ( is_admin() ) {
return;
}
$path = isset( $_SERVER['REQUEST_URI'] ) ? $_SERVER['REQUEST_URI'] : '';
if ( ! $path || '/page-slug' != $path ) {
return;
}
/**
* Replace 'subscriber' with the required role to update, can also be contributor
*/
$subscriber = get_role( 'subscriber' );
// This is the only cap needed to upload files.
$subscriber->add_cap( 'upload_files' );
}
add_action( 'init', 'mb_allow_contributor_uploads' );
Hello,
As i told you in the other thread, my subscribers already have the upload_files capability but they can't upload.
See https://support.metabox.io/topic/image-upload-does-not-work-with-mb-frontend-submission/#post-6600
I prefer wait for a fix (or a quick fix). I just hope it will be released soon 🙂
Please tell me when it's ok,
Have you tried with the code above? I tested and it works, with some CSS fix. I removed page checking. Please try again:
/**
* Allow the media uploader work on specific pages
*/
function mb_allow_subscriber_uploads() {
if ( is_admin() ) {
return;
}
/**
* Replace 'subscriber' with the required role to update, can also be contributor
*/
$subscriber = get_role( 'subscriber' );
// This is the only cap needed to upload files.
$subscriber->add_cap( 'upload_files' );
}
add_action( 'init', 'mb_allow_subscriber_uploads' );