Mapping FB data to user profile fields & "Display name as" setting

Hi guys,

Loving the Ultimate Facebook plugin, but I'm struggling to map user Facebook profile data to fields on the WordPress User's profile page. I want to pull and list the user's Facebook URL, but it doesn't seem to be pulling it across when they login/register.

-I've deleted the user and started from scratch.
-I've also tested mapping it into standard WP fields instead of the custom fields produced by my theme, but it still doesn't come across.

Are these additional fields I need to request in my Facebook App perhaps?
Is there a certain syntax I need to be using for customs fields other than just "fbm_facebook_profile" which is what the filed is labelled when inspecting the fields properties?

I'd also love to know how to default the "Display name publicly as" to "First Last" instead of "first_last".

Thank you in advance.

  • Rupok

    Hi Mike

    Hope you had a wonderful day.

    I've also tested mapping it into standard WP fields instead of the custom fields produced by my theme, but it still doesn't come across

    I tried to regenerate the issue on my test site, but I could not. I create a facebook app, configured the app, set credentials in plugin settings, and when I registered with facebook, it pulled all data perfectly. In my plugin settings, I've set "first_name" to "First name", "last_name" to "Last name" and "description" to "Bio" and all fields are being imported perfectly.

    So I assume, there is something in your site settings which is causing this. Let's fix the standard WP fields first. Can you make a plugin conflict test just to make sure no other plugin is causing this? To know more about plugin conflict test, you can check this article: https://premium.wpmudev.org/manuals/using-wpmu-dev/getting-support/

    I'd also love to know how to default the "Display name publicly as" to "First Last" instead of "first_last".

    Can you try adding the following code in your functions.php file or by creating a MU Plugin? For creating a mu plugin, create a folder named "mu-plugins" inside your "wp-content" folder. Then inside that "mu-plugins" folder, create a file with any name and with a .php extension. Now paste the code inside that file and save.

    add_action('user_register', 'registration_save_displayname', 1000);
    function registration_save_displayname($user_id) {
        if ( isset( $_POST['first_name']) &&  isset( $_POST['last_name']) ){
    		$pretty_name = $_POST['first_name'] . ' '. $_POST['last_name'];
    		wp_update_user( array ('ID' => $user_id, 'display_name'=> $pretty_name) ) ;
    	}
    }

    For getting more idea on mu plugins, you can go through this article: https://premium.wpmudev.org/manuals/wpmu-manual-2/using-mu-plugins/

    I'm looking forward to hear from you and resolve this issue as soon as possible.

    Have a nice day. Cheers!
    Rupok

  • Mike

    Sorry I should clarify that First name, Last name, Bio and Email are all pulled successfully from the user's Facebook profile as mapped in the attached image into default WP fields; but I cant pull the User's Facebook URL into a custom field.

    Is "fbm_facebook_profile" the correct field name and syntax to map to based on the method I used to find it?

    How do I test re-sync'ing this user's information without deleting the user over and then logging in again?

    I'll also try the MU Plugin you suggested for my 2nd question :slight_smile:

    Thank you.

  • Mike

    Ok so I've managed to test-fill the custom field with some data such as the users Facebook first name etc, so I know the custom field works with the plugin.

    What I can't fill is "Facebook profile" or "Facebook username" into this custom field. I need this as my theme references it to add a Facebook icon and link next to the user's posts.

    So how do I pull the FB user's profile URL? Is that the "Facebook profile" option? Do I need extended permissions on my FB App? The Ultimate Facebook plugin errorlog is empty.

    Thanks again :slight_smile:

  • Mike

    The MU plugin is throwing this error on Admin pages:

    'registration_save_displayname', 1000); function registration_save_displayname($user_id) { if ( isset( $_POST['first_name']) && isset( $_POST['last_name']) ){ $pretty_name = $_POST['first_name'] . ' '. $_POST['last_name']; wp_update_user( array ('ID' => $user_id, 'display_name'=> $pretty_name) ) ; } }
    Warning: session_start(): Cannot send session cache limiter - headers already sent (output started at /home/scoop/public_html/wp-content/mu-plugins/display_name.php:7) in /home/scoop/public_html/wp-content/plugins/wpmu-dev-facebook/lib/external/facebook.php on line 60

  • Rupok

    Hi Mike

    Hope you had a wonderful day.

    Oh, I'm really sorry. All code should be wrapped in <?php ?> tag. So the final code will be:

    <?php
    add_action('user_register', 'registration_save_displayname', 1000);
    function registration_save_displayname($user_id) {
        if ( isset( $_POST['first_name']) &&  isset( $_POST['last_name']) ){
    		$pretty_name = $_POST['first_name'] . ' '. $_POST['last_name'];
    		wp_update_user( array ('ID' => $user_id, 'display_name'=> $pretty_name) ) ;
    	}
    }
    ?>

    Can you please try this and let us know the result? If you are still facing difficulty, can you please send me message with FTP access credentials through our secure contact form here: https://premium.wpmudev.org/contact/ so I can try it myself and make it working for you?

    Subject: "Attn: Rupok"
    - FTP Username
    - FTP Password
    - FTP Host
    - Link back to this thread for reference
    - Any other relevant URLs

    Select "I have a different question" for your topic. This and the subject line ensure that it gets assigned to me.

    Have a nice day. Cheers!
    Rupok

Thank NAME, for their help.

Let NAME know exactly why they deserved these points.

Gift a custom amount of points.