0

I'm using Buddypress and just don't know where else to ask. Basically, I'm ussing the code below to take the username data and copy it to the buddypress name field, but it doesn't seem to be working. It's not copying it, and I believe because of this, it's asking me when I go to submit, if I'm sure that the data will be lost. It does actually sign up, but it won't copy the username to the display name field. If anyone has any ideas, please help.

<script type="text/javascript">
    var url = document.location.href;
    jQuery(document).ready(function() {
    //copy profile name to account name during registration
    if (url.indexOf("register/") >= 0) {

    jQuery('label[for=signup_username],#signup_username').css('display','none');
    jQuery('#field_1').blur(function(){
        jQuery("#signup_username").val(jQuery("#field_1").val());
    });
    }
    });
</script>
  • Are there any errors in the console? did you try putting console.log() to see if your code logic is being used when/where it should? – David Lee Feb 7 '17 at 1:19
  • it's saying this part: "if (url.indexOf(“register”) >= 0) {" is giving a syntax error – geektripp Feb 7 '17 at 3:44
  • Wow. It was the quotes that were copied and weren't looking as quotes to the editor. But now it's saying this: Uncaught ReferenceError: jQuery is not defined at (index):7 – geektripp Feb 7 '17 at 3:52
  • Well, I realized I hadn't loaded jQuery, but now there are no errors, and it still doesn't work. – geektripp Feb 7 '17 at 3:56
  • can you post the HTML? try checking if the selectors are working console.log(jQuery('#field_1')) – David Lee Feb 7 '17 at 16:19

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Browse other questions tagged or ask your own question.