CRED automatically creates auto drafts. The auto draft post id is stored in '_cred_cred_prefix_post_id'.
Is there a way to pass the value of this input to PHP / or any other way to get the auto draft post id for my php custom code (i.e. I am trying to integrate it with ajax_query_attachments_args, in order to allow the user to see only the current uploads - for the auto draft post)?
Hello,
There does exists one hidden field "_cred_cred_prefix_post_id" in Toolset post form, you can use it in your custom PHP codes to get it's value, like this:
$cred_cred_prefix_post_id = $_POST['_cred_cred_prefix_post_id'];
More help:
hidden link
Unfortunately that seems not to work... I am trying this:
add_filter( 'ajax_query_attachments_args', 'show_current_post_attachments' );
function show_current_post_attachments( $query = array() ) {
$cred_cred_prefix_post_id = $_POST['_cred_cred_prefix_post_id'];
$query['post_parent']= $cred_cred_prefix_post_id;
return $query;
}
But it does not return the id...
LOL. I don't know why I was struggling that much... it seems $post_id = $_POST['post_id']; works for new posts as well...
My issue is resolved now. Thank you!