0

I have created a buddypress extended profile field "description" and would like to save the data entered to the "descripion" profile field of the user (DEfault wordpress Biography description field) when user fills / edit the buddypress field.

Any clue .. how to achieve this?

Actually I'll be retriving in template as get_the_author_meta('description',$author_id) ;

So i want that the xprofile field save to this meta field as well

1 Answer 1

2

Use this action hook found in buddypress/bp-xprofile/classes/class-bp-xprofile-profiledata.php

do_action_ref_array( 'xprofile_data_after_save', array( $this ) );

You'll need to use the actual field_id for your xprofile description. This example assumes it is 25. You can get the field_idby going to wp-admin > Users > Profile Fields and clicking 'Edit' on that field. The field_id will appear in the browser url.

function echoashu_save_description( $obj ) {

    if ( $obj->field_id == 25 ) {
        update_user_meta( $obj->user_id, 'description', $obj->value );
    }
}
add_action( 'xprofile_data_after_save', 'echoashu_save_description' );
2
  • that's what i was looking for I'll test that out :) , just one thing $obj->user_id ( is it logged in user's id or retrived from the the user who's profile is being eidted
    – echoashu
    Commented Mar 31, 2016 at 8:53
  • 1
    It's the ID of the user who's profile is being edited.
    – shanebp
    Commented Mar 31, 2016 at 13:36

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.