CRED is a WordPress plugin that lets you easily build front-end forms for creating and editing content and users.
CRED User Guides include detailed documentation on creating forms, including related fields that belong to the content or the users, validating the input and displaying the forms with custom HTML styling.
When you ask for help or report issues, make sure to tell us the versions of the Toolset plugins that you have installed and activated.
Viewing 15 topics - 46 through 60 (of 6,328 total)
Problem:
Customer would like to set a minimum character limit on the search box - so for example you have to enter at least 10 characters before the search will work. Solution:
To implement the feature of disabling the submit button until there are more than 10 characters in the search box, please add and customize the following JavaScript code in your CRED form's JS box:
jQuery(document).ready(function($) {
// Reference to the search field and submit button
var $searchField = $('input[name="wpv_post_search"]');
var $submitButton = $('input[name="wpv_filter_submit"]');
// Initially disable the submit button
$submitButton.prop('disabled', true);
// Event handler for keyup on the search field
$searchField.on('keyup', function() {
var minLength = 10;
var currentLength = $(this).val().length;
// Enable or disable the submit button based on the character count
if(currentLength >= minLength) {
$submitButton.prop('disabled', false);
} else {
$submitButton.prop('disabled', true);
}
});
});
In the code above:
- The search field is referenced by its name, wpv_post_search.
- The submit button is referenced by its name, wpv_filter_submit.
- The script initially disables the submit button.
- It enables the button only when the character count in the search field is 10 or more.
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;
}
}
}