Skip Navigation

cred_save_data does not hold native Post Data in $POST

Won't fix

Reported for: Toolset Forms 1.9.6

Topic Tags: CRED API, Toolset Forms

Symptoms

When you use a Toolset form to create posts and run a cred_save_data hook on this form, you will not be able to access the native post data (title, body, etc.) from the form’s $_POST global variable.

This is so because at this point, only form-specific data and custom fields are stored in $_POST .

Workaround

This is a known limitation.

If you need to access post’s native data in a cred_save_data() hook get this data from the post object of $post_id.

$post_id is the ID of the currently edited or created post with Toolset Forms and can be accessed within any Toolset Forms hook.

You can then access the post object and its data using the get_post function.

You could also try to use a cred_before_save_data hook, which is triggered earlier. At this point, $_POST still holds the post data.

If you really need this to change please submit a feature request.

Leave
a Reply

Your email address will not be published. Required fields are marked *

You may use these HTML tags and attributes: <a href="" title=""> <abbr title=""> <acronym title=""> <b> <blockquote cite=""> <cite> <code> <del datetime=""> <em> <i> <q cite=""> <s> <strike> <strong>