Skip Navigation

[Resolved] Pass CRED Form input attribute value to PHP

This support ticket is created 3 years, 6 months ago. There's a good chance that you are reading advice that it now obsolete.

This is the technical support forum for Toolset - a suite of plugins for developing WordPress sites without writing PHP.

Everyone can read this forum, but only Toolset clients can post in it. Toolset support works 6 days per week, 19 hours per day.

Sun Mon Tue Wed Thu Fri Sat
- 9:00 – 13:00 9:00 – 13:00 9:00 – 13:00 9:00 – 13:00 9:00 – 13:00 -
- 14:00 – 18:00 14:00 – 18:00 14:00 – 18:00 14:00 – 18:00 14:00 – 18:00 -

Supporter timezone: Asia/Hong_Kong (GMT+08:00)

Tagged: 

This topic contains 3 replies, has 2 voices.

Last updated by andrei-laurentiuP 3 years, 6 months ago.

Assisted by: Luo Yang.

Author
Posts
#2066187

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)?

#2066223

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

#2066245

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...

#2067151

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!