map display_name to facebook name

Hi,

I want to map the wp display_name to the FaceBook Profile name.

Today when "John Smith" registers through FB his display name is: "john_smith"

I tried to map display_name to Name but it didn't work.

  • Alexander
    • DEV MAN’s Mascot

    @koff,

    I'm sorry for being unclear. This is under "Facebook -> Settings -> Facebook Connect section" Click "add another mapping" and map "nickname" to "name" rather than using "display_name"

    Let me know if this works. "nickname" is the other way Wordpress refers to the display_name behind the scenes.

    Thanks for being a WPMU DEV member. Let us know if we can be of any further assistance.
    Best regards,

  • Alexander
    • DEV MAN’s Mascot

    Hello again,

    I'm so sorry this has been delayed so long. I still don't have a final solution for this, as it's proving more difficult than expected. The problem before was that I didn't quite understand your question. I did get the nickname to map, but that's not what you wanted.

    I came up with this:

    This is a function that will in fact set the display name to "First Last" but for some reason it's only working if the account is registered without using Ultimate Facebook.

    add_action('user_register','default_first_last',10,1);
    
    function default_first_last($user_id){
    
    $user_meta = get_user_meta($user_id);
    
    if($user_meta->first_name && $user_meta->last_name)
    update_user_meta( $user_id, 'display_name', $user_meta->first_name." ".$user_meta->last_name);
    
    }

    This code is not working because I suspect I'm missing something here. But I'm going to check with the developer and perhaps he can point out what needs to happen to get this working.

    add_filter('wdfb-profile_sync-wp-field_value','default_display_name_from_fb',10,3);
    
    function default_display_name_from_fb($data, $map, $user_id) {
        if ($map == 'display_name')
        {
            $user_meta = get_user_meta($user_id);
    
            if($user_meta->first_name && $user_meta->last_name)
                return $user_meta->first_name." ".$user_meta->last_name;
        }
        return $data;
    }

    @Vladislav, to some up what we're trying to do here: When a new user is created, their display_name is immediately set to "first_last" the function above solves this for standard Wordpress registrations, but somehow it's not taking affect. Any ideas?

    @koff,
    Thanks for your patience, and sorry again for the delay here.\

    Best regards

Thank NAME, for their help.

Let NAME know exactly why they deserved these points.

Gift a custom amount of points.