• Hi there,

    At this moment i got an ACF field which uploads images to a custom post-type called “boats”. This field is shown on the front-end and makes an ajax call to upload the image and attach it.

    The problem is here the following code:
    ‘wp-admin/includes/ajax-actions.php’

    		if ( ! current_user_can( 'edit_post', $post_id ) ) {
    			echo wp_json_encode( array(
    				'success' => false,
    				'data'    => array(
    					'message'  => 'Error user_id:' . get_current_user_id() . ' post_id:' . $post_id,
    					//'message'  => __( 'Sorry, you are not allowed to attach files to this post.' ),
    					'filename' => $_FILES['async-upload']['name'],
    				)
    			) );
    
    			wp_die();
    		}

    The current user is an author which has the edit_boats permission but not the edit_post permission. Which results in not allowing the author to attach images to that boat.

    edit:
    When i give the user the ‘edit_post’ permission this still doesn’t work. Prob because the id is from an custom post-type (boats).

    • This topic was modified 7 years, 10 months ago by AugusGils.
  • The topic ‘wp_ajax_upload_attachment current_user_can bug’ is closed to new replies.