Skip Navigation

[Resolved] CRED user registration form validation

This support ticket is created 6 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.

This topic contains 2 replies, has 2 voices.

Last updated by Joan 6 years, 6 months ago.

Author
Posts
#892139

I'm trying to do on a CRED user registration form a validation of some fields related to a CPT. Is it possible to do related through cred_form_validate a query related to some fields of a CPT on a user form?

Thanks.

#892303

Sure it's possible, you would just use the get_posts or WP_Query of WordPress, within the hook of Toolset Forms.

Toolset's Form API is just a set of hooks, that let you fire your custom code at different points in the life of a Form.

The cred_form_validate() will provide the data from the fields, and you can then compare that data to some conditions, and either let it fail with an error which you can customize, or proceed.

To what data you compare that to, or where you get that data from, is up to the webmaster.

How could you get posts?
With the WordPress API:
https://codex.wordpress.org/Template_Tags/get_posts
https://codex.wordpress.org/Class_Reference/WP_Query

The fields from those posts can later be accessed with the WordPress API again:
https://developer.wordpress.org/reference/functions/get_post_meta/

Then, using if/else PHP native conditions and the Error array that Toolset Forms API provides, you can validate your input on the forms, using the data you pulled.

#906681

Thanks Beda!

It works fine.