Skip to:
Content
Pages
Categories
Search
Top
Bottom

Storing/Syncing with WP User meta


  • Ala7lam
    Participant

    @ala7lam

    Hi,

    I would like to start using BuddyPress but I’d rather be able to keep users’ data stored in the default WP user meta which allows met to use data with other plugins quite easily as well.

    I was wondering if there is a way to either:
    1) Sync certain fields between XProfile <=> WP User meta and to update both ways
    2) Rely completely on WP User meta and remove the profile tab while adding a custom tab where I could perhaps use a user profile plugin there such as UserPro.

    The first option is more straight I guess but I am not sure if someone was able to do something like this before?

    I would appreciate if someone could point me to examples/code snippets or functions that I (or my developer) could use to achieve this.

    Thanks!

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

  • Henry Wright
    Moderator

    @henrywright

    This would involve a big rewrite to the xProfile component. It wouldn’t be an easy task and I’d actually recommend against doing it. Instead, perhaps you could disable the component and roll your own usermeta-based solution to user profiles?


    Ala7lam
    Participant

    @ala7lam

    Thanks for your response @henrywright.

    That’s a very good suggestion. I actually had no idea that was possible.

    So you are saying I can disable the profile/Xprofile fields and create my own BP plugin component to act as a profile tab? If yes, this is good news for me!

    Thanks!


    valuser
    Participant

    @valuser

    The second ask — i can’t usefully contribute!

    for the first ask

    Assuming your new user fills in her/his profile fields on registration

    Something like the following MIGHT work.

    On FIRST login a user is redirected to say .$user -> user_login.’/profile/change-avatar/’;

    then add something like this to the functions.php file of your theme

    function alaiam(){
    
    global $current_user, $wpdb, $bp;
    
    get_currentuserinfo();
    
    $user_id = get_current_user_id();
    
    $firstname = xprofile_get_field_data( "First Name" ,$user_id);
    update_user_meta( $user_id, 'first_name', $firstname);
    
    $lastname = xprofile_get_field_data( "Last Name" ,$user_id);
    update_user_meta( $user_id, 'last_name',$lastname);
    
    $gender= xprofile_get_field_data( "Gender" ,$user_id);
    update_user_meta( $user_id, 'gender',$gender);
    
    $xdob= xprofile_get_field_data( "Date of Birth" ,$user_id);
    update_user_meta( $user_id, 'dob',$xdob);
    
    /*and so on.........*/
    
    add_action('bp_before_profile_avatar_upload_content', 'alaiam', 10, 0);

    Henry Wright
    Moderator

    @henrywright

    @ala7lam if you go to Settings > BuddyPress you should see a check box next to Extended Profiles. If you uncheck that, the xProfile component becomes disabled. Then you can add your own custom solution (using WordPress usermeta if you wish).


    Ala7lam
    Participant

    @ala7lam

    Thanks @henrywright, yes I am aware of that but had no idea we can actually develop components too 🙂 Thanks for your help!


    Ala7lam
    Participant

    @ala7lam

    Thanks @Valuser, will try that with my developer. I did notice the redirect indeed.

    Thanks!

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