Feature Requests
Share ideas, discuss and vote on requests from other users in community
 
This object is in archive! 

Custom field validation hooks

thoraxe shared this idea 6 years ago
Under Consideration

There do not appear to be any hooks that can be fired between the custom fields entry page (confproduct) and the shopping cart. While a regular expression is good to determine if a field meets criteria, when dealing with provisioning it may be necessary to validate the user's selection externally.

Using the hook documentation as our example, and referring to the hook_create_forum_account sample code, we have the following issues to contend with:

1) How do we validate that the user's desired forum name is available?

2) If it is not available, how do we alert the user?

3) If it is not available, how do we return the user to the confproduct page to update their selection (preferably with the alert message from #2).

Comments (4)

photo
1

The ShoppingCartValidateProductUpdate seems to do the trick, partly. It would seem that there should still be a dedicated hook here.

photo
1

hello, it is very simple ....

i added a demo code . please check this code

<?php

function hook_validation_forum_account($vars) {

$data = array(

'sponsor' => $vars['customfield'][24]);

$ch = curl_init();

$url = "you soft url";

curl_setopt($ch, CURLOPT_URL, $url);

curl_setopt($ch, CURLOPT_POST, true); // tell curl you want to post something

curl_setopt($ch, CURLOPT_POSTFIELDS, $data); // define what you want to post

curl_setopt($ch, CURLOPT_RETURNTRANSFER, true); // return the output in string format

$output = curl_exec($ch); // execut

curl_close($ch);

if(!$output){

$error = "This is an Error message";

return $error;

}

}

add_hook("ClientDetailsValidation",1,"hook_validation_forum_account");

?>

photo
1

Yes, we really need these! We should be able to validate custom fields better than just regex.

photo
1

Also, the data given to $params is pretty weak, at the very least the cart data should be passed. Right now it looks like the only way to get the cart details is to grab it from the SESSIONS var using the user supplied $_REQUEST['i'] var.