pods-framework / pods

The Pods Framework is a Content Development Framework for WordPress - It lets you create and extend content types that can be used for any project. Add fields of various types we've built in, or add your own with custom inputs, you have total control.
https://pods.io/
GNU General Public License v2.0
1.06k stars 265 forks source link

CPT disable "Editor" don't send post_id by "upload type custom field" #7316

Open datgausaigon opened 1 week ago

datgausaigon commented 1 week ago

Description

I need to create a Custom Post Type (CPT) with "Editor" having to be "Disabled".

Screenshot 2024-06-21 at 19 57 00

This CTP has other Custom Fields, and has an Upload Image Custom Field (Pods Image Field). And I need to programmatically handle uploading images to CPT with Custom Filed via Hook-Filter "wp_handle_upload_prefilter". If a CPT has Enable Editor then I can get the post_id in Hook-Filter "wp_handle_upload_prefilter" with code like this:

$post_id = intval( $_REQUEST['post_ID'] ?? $_REQUEST['post_id'] ?? $_REQUEST['post'] ?? 0 );

But if Editor is "Disabled", $post_id will be 0 with the above code.

I tried logging debug with the code: error_log( print_r( $_REQUEST, true ) );

Then in the log I get an array of:

[June 21, 2024 12:30:53 UTC] Array
(
 [name] => sample-image.jpg
 [action] => upload-attachment
 [_wpnonce] => 4fe6647c28
)

If I ENABLE "Editor" I can get $post_id as well. The log will be:

[21-Jun-2024 13:05:54 UTC] Array
(
    [name] => sample-image.jpg
    [action] => upload-attachment
    [_wpnonce] => 4fe6647c28
    [post_id] => 6544
)

So is there now a way for me to get the post_id when a CTP disable "Editor"?

Thanks ❤️

Version

3.2.2