Skip to:
Content
Pages
Categories
Search
Top
Bottom

Disable name change in Profile?

  • Avatar of The Sandman
    The Sandman
    Participant

    @syaman

    Hi, is there a way I can disable a user’s ability to change his/her name in his Profile in BuddyPress? I am planning a BuddyPress roll out for a secondary school and we are concerned about students faking their identities and misrepresenting themselves.

    Thank you!

Viewing 6 replies - 1 through 6 (of 6 total)
  • Not tested, but this would probably do it (put it in a plugin and activate it or add it to your theme’s functions.php file):

    <?php
    function disable_name_change( $data ) {
    if ( 1 == $data->field_id )
    $data->field_id = false;

    return $data;
    }
    add_action( 'xprofile_data_before_save', 'disable_name_change' );
    ?>

    Avatar of The Sandman
    The Sandman
    Participant

    @syaman

    Thank you I’ve pasted the text of your code into a newly created .php file and placed it in mu-plugins folder. It works nicely.

    I’ve also had to disable BuddyPress to WordPress profile syncing. Otherwise a newly created user would seem to “lose” his name completely after attempting to change it in BuddyPress’ Edit Profile.

    Thanks again!

    Avatar of gen-superman
    gen-superman
    Participant

    @gen-superman

    I tried very hard to get this to work, and I can not get that code to work, even in the default template or even by creating a blank .php with pasting in the code listed above to upload to the mu-plugins directory.

    I am very surprised that this worked for you, as I really needed this bad. Because, for some odd reason, in the WP-Profiles section, users are NOT allowed to edit their main username, but they can edit their display name, which is fine… But, in the BP Profiles section, the users can simply change their login username to anything they want. This will obviously lead to database errors and people changing their usernames to cause conflicts.

    So, this I consider is a major security risk, and there is no way to stop regular non admins from changing their usernames in the BP Profiles. Hey, at least WP got it right, by not allowing it…

    I’m not sure why the code listed above didn’t work for me. I have a totally different theme called, “Darkpress theme 1.1.”. But, I edited the functions.php file in both the themes directory and in the bp-themes where the themes are located. Because, there are actually two of the same themes located in two totally different directorys on the site. As there should be.

    But, I’m not sure if this code was suppose to go into an existing plugin or create it is as a plugin, as I tried an empty .txt file and copied the code listed above then uploaded it as a .php mu-plugin. But, that didn’t work, it honestly didn’t even recognize the code. Nor, did it change anything.

    So, does anyone have any ideas of how to STOP people from being able to change their “LOGIN Username” from being edited within the BP-PRESS profiles edit areas.

    One more thing, the WP-Registration profiles that request for new username and e-mail address, show up above the BP-PRESS profile questions and it also asks for the username. So, on the same registration page, you have two questions requesting for what their username is going to be. This is quite ridiculous, and so far their is no way to shut that part off. Does anyone have any ideas? This is quite frusterating… As, the regisration page should only ask one time for a username, but it seems that the BP-PRESS profiles is also asking for it.

    And yes if you fill out a different username for the WP-Registration username field versus the BP-Registration username field, the BP-Username field that was filled out will out win the WP-Registred username field.

    I am so confused, how do I fix this???

    Avatar of Jeff Sayre
    Jeff Sayre
    Participant

    @jeffsayre

    I tried very hard to get this to work, and I can not get that code to work, even in the default template or even by creating a blank .php with pasting in the code listed above to upload to the mu-plugins directory.

    First of all you should not be placing the code in mu_plugins. Either place it in your bp-custom.php file, create your own plugin that resides in /wp-content/plugins/, or put the code in your member theme’s functions.php file.

    But, in the BP Profiles section, the users can simply change their login username to anything they want. This will obviously lead to database errors and people changing their usernames to cause conflicts.

    Where do you see the option in BuddyPress to change your login username? The only option you have is to change your display name. This is an entirely different piece of datum.

    Yes, when a user registers for a new account, if they choose to enter the exact same datum in the username field as the “Full Name” field, then that is their choice. But, this data is stored and used in different ways. The datum from the “Full Name” field gets placed in two different tables: it populates the display_name field in the wp_users table and it is recorded in the wp_bp_xprofile_data table corresponding to the meta field entitled “Full Name” in the wp_bp_xprofile_fields table.

    When a user decides to edit their “Full Name” field via BuddyPress, the changes to that piece of datum have no affect on the login username field stored in the user_login field of the wp_user WordPress table.

    So, on the same registration page, you have two questions requesting for what their username is going to be. This is quite ridiculous, and so far their is no way to shut that part off. Does anyone have any ideas?

    This is not correct. These fields serve different purposes as detailed above. One field is the user_login, the other is the user’s display name.

    Avatar of gen-superman
    gen-superman
    Participant

    @gen-superman

    Your right, I tried this again and it worked fine… See, what I thought was that with this code, that the display name would be grayed out completely, which I don’t think it is for Admins, but regular users might see the box empty. Currently, users can still edit their display name from the bppress profile with this code, BUT when they go to save it, the changes won’t actually take place, which is a very good thing. I understand the purpose of having a login username and a display name, which I guess is fine for security purposes. But, for old school people like me, I prefer one username and one login name combo in one.

    Now, the user can still change their display name by going to the wp-profile area, and then choose which display name they want to go by. Which I guess is not that bad. But, I guess, I would still prefer to find a way to shut that off in the near future.

    But, then again, WP is so picky about using duplicate e-mails. I have not found a way to allow for users to register a new account with the same e-mail address. That can be a real pain in the rear, especially if you are testing the user registration process yourself. So, that leaves users that want to change their display name in the future with the option to change it in the WP-Profile area. Although, I prefer to find a way to shut that off entirely. But, I can’t just get rid of the WP-Profile link, because it has the ability for users to change their password and so far I don’t see a way for BP to allow users to change their password in the BP areas? Unless someone knows a way to add that option in the users BP-profiles or knows a link that leads directly to the option for a user to change just their passwords?

    I want to say that I am impressed that by adding this code to either its own blank .php file and placing it into the mu-plugins, that it worked so nicely. I did try it in the regular plugins directory and it did not take effect. I also had embedded it as you ‘Jeff Sayre’ had stated in the bp-themes template functions.php and that worked fine too.

    I then did one more test with this. I registered a new user through the registration process, and of course the Username field comes up due to WP requesting it and the BP-Display Name field comes up due to BP requesting it. Luckily, because of the code, it didn’t matter what the user entered in the BP Display Name, it would only recognize the username from the WP Username field in the registration. Which, yes I know, they are two totally different things, but I feel more at ease that this actually worked.

    Although, now users that register will be confronted with both of these questions, and I guess if they think their entering a display name for the BP-Field they will be very disappointed to find that their username will take default.

    So, for now, I guess the only remedy is by changing the label ‘display name’ that BP profile uses to ‘username’. Because, although a person enters a display name in the registration part of the BP display name field, it doesn’t show up in the WP-profile area as a nickname option. Either because of the code conflicts or BP wasn’t made to do that. Not sure. OR I guess you could just relabel to inform that display names can only be changed or created in your WP-Profile area… Oh… So confusing…

    My hats off to ‘Jeff Sayre’ and ‘Andy Peatling’. I truly hope that this might become an actual option in the newer bp press versions.

    Avatar of Jeff Sayre
    Jeff Sayre
    Participant

    @jeffsayre

    But, I can’t just get rid of the WP-Profile link, because it has the ability for users to change their password and so far I don’t see a way for BP to allow users to change their password in the BP areas?

    A user can change their password by going to their profile and clicking:

    Settings > General

    Try it here on this site!

Viewing 6 replies - 1 through 6 (of 6 total)

You must be logged in to reply to this topic.