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 - 31 through 45 (of 11,431 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;
}
}
}
Validation of the featured image in the Toolset Forms was triggering an error.
Solution:
The issue was that the PHP function 'getimagesize' expects the param to be an actual object and in the error log you shared this parameter is empty.
I deducted that this happened when you try to submit the form without the featured image, then getimagesize will try to check the size of null and error out.
I added a check to see if the field _featured_image is set before checking for the size and that fixed the issue.