Membership is allowing spaces during signup. Screwing up BuddyPress

Hi, when a new user registers, they are asked for a user name and allowed to type in something like "Jess Finn" (with the space).

Then, when they go to their BuddyPress profile (via the "Sidebar Login" plugin which has %username% in a url to get to profile), they're getting "Page Not Found" errors.

How can I fix it so that users aren't allowed to use a user name with a space?

Thanks!

  • Vubiquity
    • Premium Content Services

    And/or, where can I edit the text that says:

    "Registering for this site is easy, just fill in the fields below and we’ll get a new account set up for you in no time."

    So I can add in some stuff about no spaces allowed.

    Thanks.

  • Vinod Dalvi
    • WP Unicorn

    Hi @ice9design,

    Thanks for posting on the forum.

    How can I fix it so that users aren't allowed to use a user name with a space?

    Just try adding the following code in the functions.php file of your child theme.

    function custom_validate_username( $valid, $username ){
    
    	if ($valid) {
    		 if ( preg_match('/\s/',$username) )
     			$valid = false;
    	}
    	return $valid;
    }
     add_filter( 'validate_username', 'custom_validate_username', 10, 2 );

    "Registering for this site is easy, just fill in the fields below and we’ll get a new account set up for you in no time."

    You can change this text by translating this plugin as described on the following page.

    https://premium.wpmudev.org/blog/how-to-translate-a-wordpress-plugin/

    You can also use the following plugin to translate it.

    http://wordpress.org/plugins/codestyling-localization/

    Alternatively translate it easily as described on the following page.

    http://ronangelo.com/change-or-translate-text-on-a-wordpress-theme/

    Best Regards,
    Vinod Dalvi

  • Vubiquity
    • Premium Content Services

    Thanks! I'm a bit confused. Right now, I already have a functions.php in my child theme under buddypress/bpthemes/bp-default/

    I tried putting the code in there. No dice.

    Then I copied functions.php from my main theme to root of my child theme and added the code. Got a blank page with an error message. Also, when I copy functions.php from my main theme to my child theme (without making ANY changes), I get errors as well.

  • Vinod Dalvi
    • WP Unicorn

    Hi @ice9design,

    Thank you for your reply.

    You should add the code in the functions.php file added in the root folder of your child theme. Don't copy paste functions.php file from your parent theme in to your child instead create fresh new one file in to your child theme this is because functions.php file doesn't get overwritten in child theme therefore generates error if both the files contain duplicate functions/classes.

    Also remove the added code from functions.php in your child theme under buddypress/bpthemes/bp-default/ and only add it in the functions.php file added in the root folder of your child theme.

    Regards,
    Vinod Dalvi

  • Vubiquity
    • Premium Content Services

    Hi, Sorry but I'm now confused about editing the registration text.

    I tried adding the code described here: http://ronangelo.com/change-or-translate-text-on-a-wordpress-theme/

    But it did nothing. And I'm confused about the other links you sent, as I don't need to translate anything... just edit the text.

    I even went into the "Global Change Text" in your Ultimate Branding plugin, but it still didn't edit the text.

    • Vinod Dalvi
      • WP Unicorn

      I tried adding the code described here: http://ronangelo.com/change-or-translate-text-on-a-wordpress-theme/

      Which code have you used from that page and where have you added it?

      Please share me the code so that i can troubleshoot it.

      You should use code something like following by adding it in the functions.php file of your theme.

      function change_translate_text( $translated_text ) {
      	if ( $translated_text == 'Registering for this site is easy, just fill in the fields below and we'll get a new account set up for you in no time.' ) {
      		$translated_text = 'New Translation';
      	}
      	return $translated_text;
      }
      add_filter( 'gettext', 'change_translate_text', 20 );

      And I'm confused about the other links you sent, as I don't need to translate anything... just edit the text.

      Yes i know you want to edit the text and translating the plugin in the same language that you are using without changing your site language is the work around to change the text or just use the above code to change the text.

      Alternatively if you are using Ultimate Branding plugin then you can change it by using its "Text Change" module.

      Other way to change the text is by editing it on the following Membership plugin file on line number 390 but it is not recommended as you will have to make these changes in the plugin file and these changes will be overwritten and lost when you update the plugin and you will have to make these again after plugin updation.

      \membership\classes\Membership\Render\Page\Registration\Standard.php

      Regards,
      Vinod Dalvi

  • Vubiquity
    • Premium Content Services

    FIXED IT!

    For anyone else who's having this issue, this what was going on. Replacing "Registering for this site is easy, just fill in the fields below and we’ll get a new account set up for you in no time." didn't work because I assume there is some code in the middle of the sentence that is preventing it from being fully replaced. This is what I did:

    Installed the "Ultimate Branding" plugin and enabled "Text Change"

    At first, I had this as the text I was trying to replace: "Registering for this site is easy, just fill in the fields below and we’ll get a new account set up for you in no time." but that didn't work.

    So, I changed it to "set up for you in no time." and replaced it with:
    "set up for you in no time. PLEASE NOTE: User names cannot contain spaces (i.e. use firstnamelastname or first name-lastname)"

    Worked!

    I'm assuming using the code at this site (but with the shorter sentence to replace) would work, too: http://ronangelo.com/change-or-translate-text-on-a-wordpress-theme/

Thank NAME, for their help.

Let NAME know exactly why they deserved these points.

Gift a custom amount of points.