Skip to:
Content
Pages
Categories
Search
Top
Bottom

Stop Username prefil in Edit Profile


  • kevin008
    Participant

    @kevin008

    I love Buddy Press as part of the WPLMS theme. The only issue I have is when you edit profile and “Name (required)” field is pre filled with the User Name. This means is the user updates their Bio they can save this update and accidentally change their profile Real Name to the user name which is security risk. Please someone explain how I can prefill this field with the real name or display name rather than the user name ?

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

  • kevin008
    Participant

    @kevin008

    Please Please can someone help


    Manuel
    Participant

    @targz-1

    Indeed this behaviour seems to be hardcoded into BuddyPress, hence difficult to change.

    But I came up with a solution using Javascript: check if the field content is identical with the WP user name, and clear the field if that is the case.

    I use this solution in combination with jQuery Form Validator, that I activate on the BuddyPress “edit profile” pages: http://formvalidator.net/ – this allows to make mandatory fields really mandatory – the form shows a notification if it’s submitted while the field is empty.

    Here is some code you can add to your theme, under: buddypress/members/single/profile/edit.php

    $my_fullname = bp_get_profile_field_data( array(
      'field'   => '1',
      'user_id' => bp_loggedin_user_id()
    ) );
       		
    $my_user_info = get_userdata( bp_loggedin_user_id() );
    $my_wp_login = $my_user_info->user_login;
    
    if ( $my_fullname == $my_wp_login ) {
       		
      // clear the field with jQuery!
       				
      ?>
      <script>
      jQuery(document).ready(function($){	
        $("input#field_1").val('');
        });
      </script>
      <?php
    }
Viewing 2 replies - 1 through 2 (of 2 total)
  • The topic ‘Stop Username prefil in Edit Profile’ is closed to new replies.
Skip to toolbar