Hide Required BuddyPress Name Field
-
Hi there,
I’ve been doing a lot of research into hiding the required name profile field (since my users find it redundant and confusing), however, I can’t seem to find an answer on any topics.
The closest I stumbled upon was this BuddyPress ticket which gives this CSS code:
#register-page p { display: none;} #profile-edit-form .field_1 { display: none;} #signup_form .field_1 { display: none;}
to hide the name field and this javascript:
<script> document.getElementById("signup_username").onchange = function() {myFunction()}; function myFunction() { var x = document.getElementById("signup_username"); document.getElementById("field_1") .value = x.value } </script>
to automatically populate the Name field with their BuddyPress username upon registration. However, I don’t know where or how I should implement the javascript section. Any ideas?
Thank you for your help 🙂
Julian
-
You have 2 options. I’d recommend the 2nd:
1: Copy and paste the JavaScript to your my-theme/buddypress/members/register.php template. In this case you’ll need to copy the
<script>
tags also.
2: Create a separate file (my-theme/js/script.js for example) and paste the JavaScript into that. In this case you don’t need to copy the<script>
tags. If you go down this route you will need to enqueue the script. See this article for info on how to do that:Hey Henry,
Thank you so much! That worked perfectly.
I forgot to mention though that the “Name” profile field still shows up on theer BuddyPress profile page. Do you know any code that I could use to hide that field?
Thanks so much
haha, never mind 🙂 I totally forgot about
.profile .field_1 { display:none; }
until now. I just threw it in my child theme’s custom css.Thanks for everything.
I know this post is from a while ago, but I face the same issue. I tried the solution 2 @henrywight suggested, but it doesn’t seem to work properly for my site, nothing changed in the registration form even though I also included the CSS. This is the page I’m referring to: https://starkehand.org/registrieren/
I would appreciate your help very much! Thank you already in advance.
- You must be logged in to reply to this topic.