Custom Fields
Re-Envisioned
Support General File/image input field does not work when in group

  • Creator
    Topic
  • #6604
    ludovic.meyer
    Participant

    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,
                        ),
                    ),
                ),
            ),
        );
    
Viewing 8 replies - 11 through 18 (of 18 total)
  • Author
    Replies
  • #6752
    ludovic.meyer
    Participant

    Hello,

    My email is : me@ludovicmeyer.com

    Thank you,

    #6753
    Truong Giang
    Participant

    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' );
    
    #6754
    ludovic.meyer
    Participant

    Hello,

    As i told you in the other thread, my subscribers already have the upload_files capability but they can’t upload.
    See https://metabox.io/support/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,

    #6758
    Truong Giang
    Participant

    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' );
    
    #6816
    ludovic.meyer
    Participant

    Hello,

    I tried the code above with no success.

    I’m currently using image_advanced only for admins (“subscribers” don’t have access yet).

    But anyway, image_advanced give me other problems (validation, subscribers doesn’t see admin uploaded images when they edit the custom_post, etc etc…)

    I’m just waiting for a working simple image field 🙂

    Keep me up to date,
    Regards,

    PS : great deal on dealbuddy, thank you !

    #6893
    ludovic.meyer
    Participant

    Any news ?

    #6896
    ludovic.meyer
    Participant

    Hello Truong,

    Your code works, AAM (Advanced Access Manager) does something that lead to an “Access denied” message, even if i have the good rights. AAM is a “must have” for me. I need it to handle different type of role.

    I still need the simple “image” field :s

    Regards,

    #6904
    Truong Giang
    Participant

    Hi there,

    We are handling image field in a clonable nested group. Without cloning, it works right.
    This is a big issue, sorry for taking a long time.

Viewing 8 replies - 11 through 18 (of 18 total)
  • You must be logged in to reply to this topic.

Newsletter

Subscribe to our newsletter to receive news and tutorials for Meta Box and WordPress.


grid gear info copy caret-up caret-down trash