Skip Navigation

[Résolu] Displaying CRED error messages near field labels not working PHP 7.1

This support ticket is created Il y a 5 années et 6 mois. 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.

Aucun de nos assistants n'est disponible aujourd'hui sur le forum Jeu d'outils. Veuillez créer un ticket, et nous nous le traiterons dès notre prochaine connexion. Merci de votre compréhension.

Sun Mon Tue Wed Thu Fri Sat
- 9:00 – 13:00 9:00 – 13:00 9:00 – 13:00 9:00 – 13:00 9:00 – 13:00 -
- 14:00 – 18:00 14:00 – 18:00 14:00 – 18:00 14:00 – 18:00 14:00 – 18:00 -

Supporter timezone: Asia/Karachi (GMT+05:00)

Ce sujet contient 3 réponses, a 2 voix.

Dernière mise à jour par Waqar Il y a 5 années et 6 mois.

Assisté par: Waqar.

Auteur
Publications
#1248987

I am trying to: validate firstname and lastname in cread signup form

Link to a page where the issue can be seen: lien caché

I expected to see:

Instead, I got:

I am following this link : https://toolset.com/forums/topic/displaying-cred-error-messages-near-field-labels/

#1249145

My issue is resolved now. Thank you!

#1249151

Hi Vimal,

Thanks for sharing the update.

In my tests so far, I'm not able to make "cred_filter_field_before_add_to_form" hook work with the First and Last name fields.

Can you please share, how you managed to resolve this?

regards,
Waqar

#1249189

Hi Vimal,

Just wanted to share an update with you and for anyone else who is following this thread, the code snippet from the other thread ( https://toolset.com/forums/topic/displaying-cred-error-messages-near-field-labels/ ), will need to be updated slightly, for PHP 7.1+:


//validtion for firstname and lastname in request login form
add_filter('cred_filter_field_before_add_to_form', 'required_fields_func', 10, 2);

function required_fields_func($field, $computed_values) {
	if (in_array($field['id'], array('first_name', 'last_name'))) {

		if (!is_array($field['data'])) {
			$field['data'] = array();
		}

		$field['data']['validate']['required'] = array(
			'active' => 1,
			'value' => 1,
			'message' => 'This field is required'
		);
	}
	return $field;
}

I hope this helps.

regards,
Waqar