Skip to:
Content
Pages
Categories
Search
Top
Bottom

Forum Replies Created

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

  • tom durocher
    Participant

    @tdurocher

    @dcavins and others. The code you suggested was incorrect. Here is the correct code to fix the problem, at least it works for me with no apparent side-effects:

    function my_xprofile_sync_wp_profile( $user_id = 0 ) {
        // Bail if profile syncing is disabled.
        if ( bp_disable_profile_sync() ) {
            return true;
        }
        if ( empty( $user_id ) ) {
            $user_id = bp_loggedin_user_id();
        }
        if ( empty( $user_id ) ) {
            return false;
        }
    
        $fullname = xprofile_get_field_data( bp_xprofile_fullname_field_id(), $user_id );
        bp_update_user_meta( $user_id, 'nickname',   $fullname  );
        wp_update_user( array( 'ID' => $user_id, 'display_name' => $fullname ) );
    }
    
    remove_action( 'xprofile_data_after_save', 'xprofile_sync_wp_profile_on_single_field_set');
    function my_xprofile_sync_wp_profile_on_single_field_set( $data ) {
        echo("made it to my_xprofile");
        if ( bp_xprofile_fullname_field_id() !== $data->field_id ) {
            return;
        }
        my_xprofile_sync_wp_profile( $data->user_id );
    }
    add_action( 'xprofile_data_after_save', 'my_xprofile_sync_wp_profile_on_single_field_set' );

    tom durocher
    Participant

    @tdurocher

    Yeah. To make in even more confusing WP offers the ability to set the display_name to any of the other names (nickname, first name last name, username, and more) – I think it is username by default. Well I’ve learned something about WP’s and BP’s use of names, so maybe that will help me figure out what is going wrong with the xprofile function you sent me. It is failing to update the (apparently one single) display name. Maybe bbpress does NOT user display name for its “forum name”. Anyway, I’m missing something about the the BBPress/Buddypress integration with regard to names. Unfortunately, this is not the highest priority thing I’m working on….


    tom durocher
    Participant

    @tdurocher

    @dcavins, when I say I removed the xprofile_sync function, that was part of your suggested code. More precisely, I removed the function from the action and then added your revised function. I guess that should not prevent the forum name from being set and yet it apparently does. Well, your bullet items are good info, especially that first one. I will look at this again.

    What IS the BP nickname field, if it doesn’t use that? Maybe I’ll need to ask on the bbpress forum. Thanks again, I’ll see what I can do with this information. I’m starting to smell my theme being involved.


    tom durocher
    Participant

    @tdurocher

    Hi @dcavins. Just @mentioning you in case you’re not subscribed. I think you code can work for me if we can just get the Forum name back to being savable.

    After looking at the original function in the link you posted, I’m guessing that updating the nickname with $fullname is not wrong, but it doesn’t seem to be working. I notice that this function in the original code is attached to two actions that are different than the one you had me attach to. Could this be the problem? Remember, I have removed the original xprofile_sync function.

    add_action( 'bp_core_signup_user',      'xprofile_sync_wp_profile' );
    add_action( 'bp_core_activated_user',   'xprofile_sync_wp_profile' );
    

    Thanks,
    Tom


    tom durocher
    Participant

    @tdurocher

    Hi David,

    I have tried out your code and there’s a problem. But first, to address your question about the “name” field, when I’m talking about Forum Name I am talking about the Group (which had been called Base Profile). That is what I changed to Name, for UX reasons. However, I see that the field I’m calling “Name” is field_1 so probably I did change it from Display Name to Name but, as I think you know, that is not the problem.

    Regarding the code you gave me, that did solve the problem of not updating the WP First and Last name fields. However, it also prevented changes to the forum name or display name or whatever you want to call the name in the Forum Profile. I’m tempted to try commenting out the line:

    bp_update_user_meta( $user_id, 'nickname', $fullname );

    but I’m working on a live site with quite a bit of action and got a little spooked that I might change everybody’s existing posts/names, so for now I’ve just removed all your code.

    Thanks,
    Tom


    tom durocher
    Participant

    @tdurocher

    Thanks for your answer. I believe it will work for me but it may take me a day or two to check it all out.


    tom durocher
    Participant

    @tdurocher

    David (@dcavins), do you have any ideas why I wouldn’t be seeing the Display Name under Edit Profile, as you said it should? Or why Buddypress overrides important BBpress fields for editing the forum profile? I think there must be a way around this. I do not see that Memberpress is involved in this profile page at all (no apparent mepr classes or js shown in developer tools). Thanks very much for any help.


    tom durocher
    Participant

    @tdurocher

    Ah, thanks for the response. The url I’m using is, for example, https://masteringid.com/members/testmember/profile/edit/group/1/, which produces the following form:
    Edit Profile
    Editing “Forum username” Profile Group
    Name (required)

    This field may be seen by: Everyone
    Forum Signature

    Note that I have changed “base profile” to “forum username” as it seemed more to the point. So I think this is the page you are referring to but there is no Display Name field shown. I don’t so much need the First and Last Name fields as the display name field, because, although changing the forum username will change the display name, it also changes the First and Last Name (through the “Sync with WP profile” checkbox.

    BBpress alone shows First Name, Last Name, Nickname, and the Display Name dropdown. If I could have the Nickname and Display Name fields, or even just the Display Name field, I think I’d be okay.


    tom durocher
    Participant

    @tdurocher

    Doesn’t look like anybody’s going to help us here, Marcus. If I find the answer, other than getting rid of Buddypress, I’ll let you know. Please do the same for me if you find an answer. So far I have come up empty.


    tom durocher
    Participant

    @tdurocher

    Wow, I’ve just discovered that if I deactivate Buddypress, I can change all the account fields: first name, last name, nickname AND display name. This is what I want with Buddypress enabled and I see that it works this way on this forum here, but I can’t see what I have done in Buddypress to break this.

Viewing 10 replies - 1 through 10 (of 10 total)
Skip to toolbar