Skip to:

how to create a new field in profile fields?

  • Masoud


    i am using latest version of wordpress and buddypress.
    i want to create a new field by code, in group1 (which will be appeared on signup page) so when user is signing up,
    see that box and fill it, and cannot edit it after the account creation (for example just like USERNAME!)
    (you set it once, and it cannot be edited after…)

    and then so i want to call that field later, and assing data to it like:

    xprofile_set_field_data ('First Name', $user_data->ID, $identity->name->givenName);
     xprofile_set_field_data ('Last Name', $user_data->ID, $identity->name->familyName);
     xprofile_set_field_data ('WHO INFORMED YOU', $user_data->ID, $identity->personname);

    someone suggested me this code to put it in bp-custom (but it’s not working) :

    function bp_add_custom_buddy_friend() {
    	if ( !xprofile_get_field_id_from_name('personname') && 'bp-profile-setup' == $_GET['page'] ) {		$country_list_args = array(
    		       'field_group_id'  => 1,
    		       'name'            => 'whoinformedyou',
    		       'description'	 => 'write your friend's name who informed you about us
    if no one told you about us, then write NoBody.',
    		       'can_delete'      => true,
    		       'field_order' 	 => 2,
    		       'is_required'     => true,
    		       'type'            => 'textbox',
    		       'order_by'	 => 'custom'
    add_action('bp_init', 'bp_add_custom_buddy_friend');


    Extra information:
    i am using OneAll Social Login Plugin, to put social login buttons in my login form.
    in the usual signup form, i put an extra textbox (which user must fill it), in order for me to know, how this user is informed abt my website,
    the question is this:
    who informed you about this website? (if a friend, then write his/her name, if no one, simply write NoBody)

    so if a friend suggested, the user simply write down a name(just a text, not linked to anybody’s profile)
    and if not (he/she will write NoBody)
    when you login from social-login, this will not be enabled!
    so i want to create a new field, and call it from social-login.
    so if a user is signed in from social login,
    a pop up appears and force the user to enter that field.
    how can i create this ?
    tnxxxx a lot for any help.

Viewing 1 replies (of 1 total)

  • Masoud


    i’ve managed to create a extra field by ID, and this is the function to save it.
    it’s name is “person_relation”.

    add_action( 'personal_options_update', 'my_save_extra_profile_fields' );
    add_action( 'edit_user_profile_update', 'my_save_extra_profile_fields' );
    function my_save_extra_profile_fields( $user_id ) {
    	if ( !current_user_can( 'edit_user', $user_id ) )
    		return false;
    	/* Copy and paste this line for additional fields. Make sure to change name '' to the field ID. */
    	update_usermeta( $user_id, 'person_relation', $_POST['person_relation'] );

    1) any suggestion on how should i make this box appear on group 1 ?
    * or in the setting page?
    2) how should i get the value of it? (it’s a text input)? i heard that i have to use “POST[]” method? is it the right way? and how?

Viewing 1 replies (of 1 total)
  • You must be logged in to reply to this topic.
Skip to toolbar