Skip Navigation

[Resolved] It works not user repetition, but I can not upload images

This support ticket is created 6 years, 7 months ago. 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.

Sun Mon Tue Wed Thu Fri Sat
8:00 – 12:00 8:00 – 12:00 8:00 – 12:00 8:00 – 12:00 8:00 – 12:00 - -
13:00 – 17:00 13:00 – 17:00 13:00 – 17:00 13:00 – 17:00 13:00 – 17:00 - -

Supporter timezone: America/New_York (GMT-04:00)

This topic contains 16 replies, has 3 voices.

Last updated by pedroS-6 6 years, 6 months ago.

Assisted by: Christian Cox.

Author
Posts
#796759

I am trying to:
Hi, to be able to make a single credit form field, you advised me to include in fuctions.php (public_html / pullmantur / wp-content / themes / dt-the7) the following code
add_filter('cred_form_validate','func_validate_usuario_denuncia',10,2);
function func_validate_usuario_denuncia($error_fields, $form_data){

//field data are field values and errors
list($fields,$errors)=$error_fields;

if ($form_data['id']==36925){

$args = array(
'meta_query' => array(
array('key' => 'wpcf-usuario-denuncia',
'value' => $_POST['wpcf-usuario-denuncia']
)),
'post_type' => 'denuncia',
'posts_per_page' => -1
);
$posts = get_posts($args);

//check if birthday value is already on the database

if (count($posts) > 0){

//set error message for my_field

$errors['wpcf-usuario-denuncia']='Usuario ya existente, por favor utilice un nuevo usuario, gracias';

}

}

return array($fields,$errors);

}

it works, but it makes it impossible to upload files on that form. Within the same fuctions.php, I have other codes like these

<?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' );

//* Excluye páginas específicas de los resultados de búsqueda en WordPress. Las estáticas y las del formulario de denuncia de las empresas

function filtro_paginas_especificas( $query ) {

if ( $query->is_search && $query->is_main_query() ) {

$query->set( 'post__not_in', array( 35563,35532,35542,35534,35536,35538,35544,35540,35939 ) );

}

}

add_filter( 'pre_get_posts', 'filtro_paginas_especificas' );

add_filter('cred_form_validate','func_validate_usuario_denuncia',10,2);
function func_validate_usuario_denuncia($error_fields, $form_data){

//field data are field values and errors
list($fields,$errors)=$error_fields;

if ($form_data['id']==36925){

$args = array(
'meta_query' => array(
array('key' => 'wpcf-usuario-denuncia',
'value' => $_POST['wpcf-usuario-denuncia']
)),
'post_type' => 'denuncia',
'posts_per_page' => -1
);
$posts = get_posts($args);

//check if birthday value is already on the database

if (count($posts) > 0){

//set error message for my_field

$errors['wpcf-usuario-denuncia']='Usuario ya existente, por favor utilice un nuevo usuario, gracias';

}

}

return array($fields,$errors);
}

It also interferes with cred, its update.
I had to change it to its original state because everything started to work badly.
What is the problem?
can put the code right for me, it is clear that I do not do it correctly because I have no knowledge of php.
Link to a page where the issue can be seen:

I expected to see:

Instead, I got:

#796890

REDACTED

#801341

Nigel
Supporter

Languages: English (English ) Spanish (Español )

Timezone: Europe/London (GMT+00:00)

Hi Pedro

Looking at that code it doesn't appear to do anything other than check if a post with the same field 'wpcf-usuario-denuncia' has already been submitted, and shouldn't interfere with uploading images.

I could take a look at your site to see if I can see what's happening, but I can't access the back-end with the credentials you provided in your update, I get a too-many-redirects error. (I have edited that so that they are not visible in this public forum.)

If you can ensure access to the back end is possible I will look.

Can you also confirm what page this CRED form is on?

I'm going to mark your next reply as private in case you need to provide updated credentials.

#838522

Please, tell me what the changes have been because I have to make the same changes in different web pages.

#843317

Hi, Nigel is on holiday this week so I will be helping with this ticket. I hope that's okay. Unfortunately I'm having the same problem Nigel had. When I try to visit this URL, I see an error:
hidden link
The error is "This page isn’t working. hidden link redirected you too many times."
I've tried in several different browsers but I cannot access wp-admin. When I go to /wp-login.php directly, I get a different error: "502 bad gateway".

#843911

Could you tell me from which country are you trying to enter? I'm allowed Uk, but maybe it's from another one and I do not have it activated.

#844034

I'm in USA, and Nigel is in Ireland.

#846405

I think you already have authorization, if not, let me know.

#847351

Okay thanks, I am able to log in now. I assume we are talking about the form on this page:
hidden link
Is this correct?

I cannot see anything obviously wrong, so I would like to create a clone of your site using the All-in-One Migration plugin. Then I can install the clone locally and run some additional tests without breaking the live site. Please stand by and I will update you shortly.

#852362

Thank you.
Yes, everything works fine because I deleted the code.
your team told me to include this in fuctions.php

add_filter('cred_form_validate','func_validate_usuario_denuncia',10,2);
function func_validate_usuario_denuncia($error_fields, $form_data){

//field data are field values and errors
list($fields,$errors)=$error_fields;

if ($form_data['id']==36925){

$args = array(
'meta_query' => array(
array('key' => 'wpcf-usuario-denuncia',
'value' => $_POST['wpcf-usuario-denuncia']
)),
'post_type' => 'denuncia',
'posts_per_page' => -1
);
$posts = get_posts($args);

//check if birthday value is already on the database

if (count($posts) > 0){

//set error message for my_field

$errors['wpcf-usuario-denuncia']='Usuario ya existente, por favor utilice un nuevo usuario, gracias';

}

}

return array($fields,$errors);

}

I guess in the next direction

public_html/pullmantur/wp-content/themes/dt-the7

and adding it to the current one

This is the result of put it together:

<?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' );

//* Excluye páginas específicas de los resultados de búsqueda en WordPress. Las estáticas y las del formulario de denuncia de las empresas

function filtro_paginas_especificas( $query ) {

if ( $query->is_search && $query->is_main_query() ) {

$query->set( 'post__not_in', array( 35563,35532,35542,35534,35536,35538,35544,35540,35939 ) );

}

}

add_filter( 'pre_get_posts', 'filtro_paginas_especificas' );

add_filter('cred_form_validate','func_validate_usuario_denuncia',10,2);
function func_validate_usuario_denuncia($error_fields, $form_data){

//field data are field values and errors
list($fields,$errors)=$error_fields;

if ($form_data['id']==36925){

$args = array(
'meta_query' => array(
array('key' => 'wpcf-usuario-denuncia',
'value' => $_POST['wpcf-usuario-denuncia']
)),
'post_type' => 'denuncia',
'posts_per_page' => -1
);
$posts = get_posts($args);

//check if birthday value is already on the database

if (count($posts) > 0){

//set error message for my_field

$errors['wpcf-usuario-denuncia']='Usuario ya existente, por favor utilice un nuevo usuario, gracias';

}

}

return array($fields,$errors);
}

and everything started worked badly
sure I did not know how to do well
I will stand by

#857426
Screen Shot 2018-05-08 at 10.33.47 AM.png

Okay I was able to make a clone of your site and install it locally.
1. I deactivated all plugins except CRED, Layouts, Types, and Views.
2. I added the custom code you pasted above to the theme's functions.php file.
3. I submitted the form at /pullmantur with the Usario "pgarrido" and included an image file in the Archivos adjuntos field
4. An error was shown "Usuario ya existente, por favor utilice un nuevo usuario, gracias", and the image file I included in the archivos adjuntos field is still included as expected.
5. I changed the usario to "pgarridoabc" and submitted the form again. This time, no error was shown.
6. I edited the new Denuncias post in wp-admin and I can see the information I submitted. The image file I attached to archivos adjuntos is attached to this post as expected.

If you disable all plugins except CRED, Layouts, Types and Views, then test again, is the error message working as expected? Is there anything else I need to do to replicate the problem?

#858936

Thank very much for your help Christian. I'm going to need two plugin:
Theme My Login
Peter's Login Redirect
because I have not yet learned how to access users and redirect them to each personalized page, and I'm going bad of time.
If it does not work , I'll ask you for help again.
best regards. Yolanda

#859090

Okay that's fine, or you can activate Maintenance Mode temporarily using a Maintenance Mode plugin. Then your site won't be accessible temporarily.

#859423

everything works already perfect. I just had a problem updating CRED plugin

Toolset CRED
Desactivar | Registrado
Create Edit Delete WordPress content (ie. posts, pages, custom posts) from the front end using fully customizable forms

Versión 1.9.5 | Por OnTheGoSystems | Ver detalles
Error en la actualización: {"success":true,"data":{"update":"plugin","slug":"cred-frontend-editor","oldVersion":"Versi\u00f3n 1.9.5","newVersion":"Versi\u00f3n 1.9.6.1","plugin":"cred-frontend-editor\/plugin.php","pluginName":"Toolset CRED"}}

#859982

I've fixed it, I've uploaded via ftp