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 - 646 through 660 (of 1,294 total)
Problem:
Using a form or a content template in a widget
Solution:
The thing is that Toolset do not control the header, footer or sidebars. You can control few theme options of header, footer or sidebar if you are using integrated theme then you will see few theme options.
So, there are two ways, either you should create a content template where you should add a two column grid and add the from on one column and your desired content on another column.
Problem:
The user would like to validate an image field(repeatable) in a Toolset form for the image type, size, dimensions, and number of images
Solution:
This will require custom code. Check this example code:
add_action('cred_form_validate', 'my_image_validation_func',10,2);
function my_image_validation_func($error_fields, $form_data) {
// all the valid file types
$file_types = array('image/jpeg','image/png','image/jpg');
$max_size = 5 * 1024 * 1024;
$forms = array( 1806 );
// Field data are field values and errors
list($fields,$errors)=$error_fields;
if (in_array($form_data['id'], $forms ) && (isset($_FILES['wpcf-book-images']['type']))) {
// 1. Minimum number of photos is '3'.
if ( count( $_FILES['wpcf-book-images']['name'] ) < 3 ) {
$errors['wpcf-book-images'] = 'Add at least 3 images';
return array( $fields, $errors );
}
// 2. Dimensions of the photo should be at least 350 (height) x 350 (width).
foreach ( $_FILES['wpcf-book-images']['tmp_name'] as $tmp_image ) {
$sizes = getimagesize( $tmp_image );
if ( $sizes[0] < 350 || $sizes[1] < 350 ) {
$errors['wpcf-book-images'] = 'An image is too small. Images should be at least 350x350';
return array( $fields, $errors );
}
}
// 3. The file types should be JPG, PNG and JPEG.
foreach ( $_FILES['wpcf-book-images']['type'] as $type ) {
if ( !in_array( $type, $file_types ) ) {
$errors['wpcf-book-images'] = 'Image file type is not supported: ' . $type;
return array( $fields, $errors );
}
}
// 4. Maximum file size should be 5MB.
foreach ( $_FILES['wpcf-book-images']['size'] as $size ) {
if ( $size >= $max_size ) {
$errors['wpcf-book-images'] = 'An Image is too big. Images should less than 5MB';
return array( $fields, $errors );
}
}
}
//return result
return array($fields,$errors);
}