Problem:
Tell us what you are trying to do?
ensure a user_email field from a register form is saved as lowercase
Is there any documentation that you are following?
https://toolset.com/documentation/programmer-reference/cred-api/#cred_before_save_data
Is there a similar example that we can see?
trying this:
add_action('cred_before_save_data', 'my_before_save_data_action',10,1);
function my_before_save_data_action($form_data)
{
// if a specific form
// 61544 = register form v2
if ($form_data['id']== 61544)
{
if (isset($_POST['user_email']))
{
$lowercaseemail = strtolower($_POST['user_email']);
$_POST['user_email'] = $lowercaseemail;
}
}
}
Solution:
The approach you took is correct, I believe the issue might be with the missing 'wpcf' prefix in the field selection.
Can you please try the following code to see if it achieves what you need?
add_action("cred_before_save_data", "my_before_save_data_action", 10, 1);
function my_before_save_data_action($form_data)
{
// if a specific form
// 61544 = register form v2
if ($form_data["id"] == 61544) {
if (isset($_POST["user_email"])) {
$lowercaseemail = strtolower($_POST["user_email"]);
$_POST["wpcf-user_email"] = $lowercaseemail;
}
}
}