Home › Forums › General Issues › Conditional logic in register field › Reply To: Conditional logic in register field
Hi Nicolas,
Normally, you could use acf conditional logic in front end.
Anyway, with this Jquery snippet you could hide/show you fields only when “Joueur” is selected :
$( function(){
//Hide all acf fields targeting their class
$('.acf-user-register-fields').hide();
// Get the value from the selected option in a dropdown and show previously hidded fields
var selectedVal = $( "#wp_rar_user_role option:selected" ).val();
if(selectedVal == 'joueur') {
$('.acf-user-register-fields').show();
}
console.log(selectedVal);
});
Tested and working with jquery 3.x
I’m not sure it’s the best way to do it, but let me know if it helps.
RemSEO
Welcome to the Advanced Custom Fields community forum.
Browse through ideas, snippets of code, questions and answers between fellow ACF users
Helping others is a great way to earn karma, gain badges and help ACF development!
We use cookies to offer you a better browsing experience, analyze site traffic and personalize content. Read about how we use cookies and how you can control them in our Privacy Policy. If you continue to use this site, you consent to our use of cookies.