This support ticket is created vor 7 Jahre, 11 Monate. There's a good chance that you are reading advice that it now obsolete.
This is the technical support forum for Toolset - a suite of plugins for developing WordPress sites without writing PHP.
Everyone can read this forum, but only Toolset clients can post in it. Toolset support works 6 days per week, 19 hours per day.
Heute stehen keine Supporter zur Arbeit im Werkzeugsatz-Forum zur Verfügung. Sie können gern Tickets erstellen, die wir bearbeiten werden, sobald wir online sind. Vielen Dank für Ihr Verständnis.
When i duplicate this code for the cred-form to edit content (i only replaced the form id, the field name is the same in both forms) and place in my functions.php i get a white screen.
The way we placed the code:
Image size CE form - Create
function cred_image_resolution_validation( $field_data, $form_data ) {
// Field data are field values and errors
list( $fields, $errors ) = $field_data;
//Run the rest of code for this CRED ONLY and IF the file is upload type and size are set.
if ( ( 4483 == $form_data['id'] ) && ( isset( $_FILES['wpcf-ce-logo']['tmp_name'] ) ) ) {
$check = getimagesize( $_FILES['wpcf-ce-logo']['tmp_name'] );
if ( $check !== false ) {
$awidth = $check[0];
$aheight = $check[1];
if ( ($width < 300) && ($height < 300) ) {
$errors['ce-logo'] = 'Sorry, too small image.';
}
} else {
$errors['ce-logo'] = 'Sorry this is not a valid image file.';
}
}
return array( $fields, $errors );
}
>>
function cred_image_resolution_validation( $field_data, $form_data ) {
// Field data are field values and errors
list( $fields, $errors ) = $field_data;
//Run the rest of code for this CRED ONLY and IF the file is upload type and size are set.
if ( ( 4459 == $form_data['id'] ) && ( isset( $_FILES['wpcf-ce-logo']['tmp_name'] ) ) ) {
$check = getimagesize( $_FILES["wpcf-ce-logo"]["tmp_name"] );
if ( $check !== false ) {
$width = $check[0];
$height = $check[1];
if ( $width < 300 && $height < 300 ) {
$errors['ce-logo'] = 'Sorry, too small image.';
}
} else {
$errors['ce-logo'] = 'Sorry this is not a valid image file.';
}
}
return array( $fields, $errors );
}
>>
However I see that you say you are getting a white screen, in this case I would like for you to enable the wordpress debugging in order for us to see the error reports of what is causing the white screen. versteckter Link
Once you have done this please let me know the error that is being displayed.
Error code:
Fatal error: Cannot redeclare cred_image_resolution_validation() (previously declared in /var/www/vhosts/creativematter.nl/httpdocs/projects/c2m/wp-content/themes/dt-the73/functions.php:61) in /var/www/vhosts/creativematter.nl/httpdocs/projects/c2m/wp-content/themes/dt-the73/functions.php on line 97
functions.php:
/**
* Vogue theme.
*
* @since 1.0.0
*/
// File Security Check
if ( ! defined( 'ABSPATH' ) ) { exit; }
/**
* Set the content width based on the theme's design and stylesheet.
*
* @since 1.0.0
*/
if ( ! isset( $content_width ) ) {
$content_width = 1200; /* pixels */
}
/**
* Initialize theme.
*
* @since 1.0.0
*/
require( trailingslashit( get_template_directory() ) . 'inc/init.php' );
/*** MODS WP_CRED_DELETE BUTTON_REFRESH ***/
add_filter('cred_success_redirect_4918', 'redirect_to_parent_func', 10, 3);
add_filter('cred_success_redirect_5825', 'redirect_to_parent_func', 10, 3);
function redirect_to_parent_func($url, $post_id, $form_data) {
$parent_id = get_post_meta( $post_id, '_wpcf_belongs_profielen_id', true);
$url = get_permalink( $parent_id ) . '?cred-edit-form=6013';
return $url;
}
/*** MODS WP_VIEWS_FILTER_USER_MIJN_GEGEVENS ***/
function get_wp_user_role() {
global $current_user;
$user_roles = $current_user->roles;
$user_role = array_shift($user_roles);
return $user_role;
}
add_shortcode('wpv-post-get-wp-user-role', 'get_wp_user_role');
add_action('init', 'add_mapped_shortcodes_on_init');
function add_mapped_shortcodes_on_init() {
WPBMap::addAllMappedShortcodes();
}
/*** Min size ce logo ***/
add_filter('cred_form_validate_4844', 'cred_image_resolution_validation',10,2);
function cred_image_resolution_validation($field_data, $form_data)
{
// Field data are field values and errors
list($fields,$errors)=$field_data;
//Run the rest of code for this CRED ONLY and IF the file is upload type and size are set.
if (( 4844 == $form_data['id']) && (isset($_FILES['wpcf-ce-logo']['tmp_name']))) {
$check = getimagesize($_FILES["wpcf-ce-logo"]["tmp_name"]);
if($check !== false) {
$width = $check[0];
$height = $check[1];
if($width < 336 && $height < 280) { $errors['Logo'] = 'Deze afbeelding is te klein! Gebruik minimaal de aangegeven maat: 336x280px. (Een afbeelding met andere verhoudingen wordt bijgesneden)'; } } else { $errors['ce-logo'] = 'Sorry this is not a valid image file.'; } }return array($fields,$errors); }
/*** Min size ce logo - edit ***/
add_filter('cred_form_validate_5794', 'cred_image_resolution_validation',10,2);
function cred_image_resolution_validation($field_data, $form_data)
{
// Field data are field values and errors
list($fields,$errors)=$field_data;
//Run the rest of code for this CRED ONLY and IF the file is upload type and size are set.
if (( 5794 == $form_data['id']) && (isset($_FILES['wpcf-ce-logo']['tmp_name']))) {
$check = getimagesize($_FILES["wpcf-ce-logo"]["tmp_name"]);
if($check !== false) {
$width = $check[0];
$height = $check[1];
if($width < 336 && $height < 280) { $errors['Logo'] = 'Deze afbeelding is te klein! Gebruik minimaal de aangegeven maat: 336x280px. (Een afbeelding met andere verhoudingen wordt bijgesneden)'; } } else { $errors['ce-logo'] = 'Sorry this is not a valid image file.'; } }return array($fields,$errors); }
>>>>
So the issue is being caused by a duplicate function name.
To fix this all you need to do is change the function name of one of the functions so it can be unique.
/*** Image size CE form - Edit ***/
add_filter('cred_form_validate_4459', 'cred_image_resolution_validation2',10,2);
function cred_image_resolution_validation2($field_data, $form_data)
{
// Field data are field values and errors
list($fields,$errors)=$field_data;
//Run the rest of code for this CRED ONLY and IF the file is upload type and size are set.
if (( 4459 == $form_data['id']) && (isset($_FILES['wpcf-ce-logo']['tmp_name']))) {
$check = getimagesize($_FILES["wpcf-ce-logo"]["tmp_name"]);
if($check !== false) {
$width = $check[0];
$height = $check[1];
if($width < 300 && $height < 300) { $errors['ce-logo'] = 'Sorry, too small image.'; } } else { $errors['ce-logo'] = 'Sorry this is not a valid image file.'; } }return array($fields,$errors); }
/*** END ***/
>>