Skip Navigation

[Resolved] Validation via PHP

This support ticket is created 3 years, 11 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
- 10:00 – 13:00 10:00 – 13:00 10:00 – 13:00 10:00 – 13:00 10: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/Kolkata (GMT+05:30)

This topic contains 5 replies, has 2 voices.

Last updated by lesT 3 years, 11 months ago.

Assisted by: Minesh.

Author
Posts
#1938731
Toolset 2-8-2021.png

Tell us what you are trying to do?
Validate form fields before update
Is there any documentation that you are following?
many examples

I spent hours trying to get this code to work without realizing I needed
if ($fields['wpcf-display']['value']!='y')
instead of if ($fields['display']['value']!='y')
all the examples of this code I found online did not have the wpcf
can you pls advise why, in my case, it was required

Also, is the: return array($fields,$errors);
supposed to display the error message in the field itself, because in my case, the error message is displaying in a large area above the form

Also, can you advise me what line of php code is required to access the google lat/lon coordinates (after google goeodes the text form of address)
Thanks very much

#1938779

Now that I've discovered the need for wpcf, I see other examples where it's used
A follow on question, if I wanted to update fields would it be possible by including in the same snippet the line-
update_post_meta( $post_id, 'wpcf-display', 'ABCDE' );}
if so how would I obtain $post_id
Thanks

#1938953

Minesh
Supporter

Languages: English (English )

Timezone: Asia/Kolkata (GMT+05:30)

Hello. Thank you for contacting the Toolset support.

Can you please first clarify what field(s) you want to validate and what field you want to update after you submit the form and with what value.

What is your problem URL, where you added your form and I will require to adjust the code you added once you share your exact requirements.

*** Please make a FULL BACKUP of your database and website.***
I would also eventually need to request temporary access (WP-Admin and FTP) to your site. Preferably to a test site where the problem has been replicated if possible in order to be of better help and check if some configurations might need to be changed.

I have set the next reply to private which means only you and I have access to it.

#1938969

Thanks for the reply, I have resolved everything except for

Also, can you advise me what line of php code is required to access the google lat/lon coordinates (after google has geocoded the text form of address)
Thanks very much

#1938975

Minesh
Supporter

Languages: English (English )

Timezone: Asia/Kolkata (GMT+05:30)

Great that you resolve all other issues.

You can use the Types PHP API function types_render_field() to get the lat/long based on your address field. For example:

$res = types_render_field("address-field-slug", array("format"=>"FIELD_LATITUDE, FIELD_LONGITUDE"));

More info:
=> https://toolset.com/documentation/customizing-sites-using-php/functions/#address

#1950519

My issue is resolved now. Thank you!