Ultimate Facebook with custom field on frontend

Hello WPMU Dev

I desperately hope you can help me out as i seem to make no progress after reading other threads on this.

What i need to achieve is the following:
1. add a custom field to the sign-up button
2. display the field above the button on a normal page where button and field are inserted via the shortcode
3. prefill the custom field by URL parameters
4. store the field value to database upon FB connect

I tried the code given here
The field did not show up on the page where i place the shortcode nor on the wp-login.php?action=register page.

Please help me.

Thank you very much and i'm looking forward to hearing from you.


  • Tyler Postle

    Hey Tobias,

    Hope you are well today and thanks for your question!

    Have you tried looking at this post? https://premium.wpmudev.org/forums/topic/custom-user-profile-and-added-registration-fields#post-147030 this was posted by one of our devs, that should give you a good start. If not, then be sure to post back here instead of on the linked thread. It will keep everything in one place so we can provide more efficient support for you :slight_smile:

    Let us know how that goes!

    All the best,

  • Tobias

    Hi Tyler,

    thanks for coming back to me. Yeah i tried the code in the referrenced thread as well on a test site with the twentyfourteen theme and no other plugins active. Unfortunately without success: no additional field shows on the frontend (which is what i need) nor the registration page.

    You find the testdomain here:


    Is the referrenced code supposed to show an additional field next to the FB button and then save the field's value in the database? I hope so cause then all that's needed is to make it show up :slight_smile:

    Looking forward to hearing from you again.


  • Umesh Kumar

    Hi @Tobias,

    Hope you are doing great :slight_smile:

    1. I had a look at your site, I could see the custom field "My Description" there on your Facebook registration form. I'm attaching a screenshot for your reference. Or I interpreted you wrong?

    Here is the registration form

    I checked up the same with shortcode on my local site and the code to add a custom field works fine there too.
    2. The custom field displays above the button.
    3. I'm afraid Facebook doesn't allows you to provide a default value for a text input, you can refer it here
    4. The field value can be updated to user meta using the given code

    function wpmu_wdfb_user_registered ($user_id, $registration) {
            if ( isset( $registration['myname'] ) ) {
    	  update_user_meta($user_id, 'myname', $registration['myname']);
        add_action('wdfb-user_registered', 'wpmu_wdfb_user_registered ', 10, 2);

    Later on you can access the stored value from user meta using
    get_user_meta( $user_id, 'myname', true);

    Hope it helps you.

    In case you have further doubts please post back, I'll be happy to help :slight_smile:

    Thanks and Cheers ..!

  • Tobias

    Hi Umesh,

    yes, i'm good. hope you too!

    thanks for having a look, i really appreciate it.

    i feared the field would be part of the FB form. what i hoped to find was how to add a field next to the button on the page - not part of the FB form. and then saving this data to the user after he comes back from facebook.

    i understand the code you referrenced does not do this, correct?

    is there any other way you can imagine this to work:
    have a field on the page next to the FB button, store the value temporarily (e.g. session value?) or pass it on via URL parameters and then add it to the user's profile after "he comes back from FB"?

    i guess that's something for a developer. so right now i need to confirm it's doable and maybe you have specifics on how to do it so i can engage an outsourcer effectively.

    Thank you very much!

  • Tobias

    Hi Umesh,

    I understand it can be tricky so let's think of the simplest scenario like url?day=1 or url?day=2
    One parameter that's just a number. All parameters would be predefined. 1, 2... would be values set in an array. The value would be stored in a custom field in the database.

    Then i can call the simplified value (1,2...) and transfer it into something meaningful once it's called for later on (if 1 show this...).

    Thank you for helping me out!


  • Umesh Kumar

    Hi @Tobias,

    I just want the perfect solution for you, hope you'd be patient enough :slight_smile:

    So is it really necessary to pass the value through the URL?

    And you need it while user is registering, right?

    As you said it could be a session thing, so If I get that thing right, that value is for your own use.

    In that case you can just store the value directly when user is created, you won't need a field for that unless the field value is dependent on user.

    function wpmu_wdfb_user_registered ($user_id, $registration) {
           $custom_variable = "This is my value, it can be anything. You can get the value with some custom logic";
           update_user_meta($user_id, 'custom_variable', $custom_variable);
        add_action('wdfb-user_registered', 'wpmu_wdfb_user_registered ', 10, 2);

    After that you can use that value anywhere by just fetching it from user meta.

    I'm answering based on what I understand from your reply, So in case you are expecting something else please post back.

  • Tobias

    Hi Umesh,

    quite the contrary - no pacience needed with THAT awesome support here! Thank you for going the extra mile.

    I'm starting to see light at the end of the tunnel! I tested your function and it does save the custom variable upon registration.

    So what we need is:
    Hook it also to the login besides the registration process so that the value can be updated over time. I looked for something like wdfb-USER_LOGIN to replace wdfb-user_registered but couldn't find it.

    Fill the custom variable with a field value because as you suspected the value will differ between users.

    Maybe you have some ideas? This will effectively allow event registration via your Facebook plugin and I hope would be helpful to others as well.

    Thank you

  • Umesh Kumar

    Hi @Tobias,

    To hook to Facebook login as well as Facebook registration you can use the following two hooks

    add_action( 'wdfb-user_registered', 'wpmu_wdfb_user_custom_value');
    add_action( 'wdfb-login-facebook_login', 'wpmu_wdfb_user_custom_value');
    function wpmu_wdfb_user_custom_value ( $user_id ) {
        $custom_variable = "This is my value, it can be anything. You can get the value with some custom logic";
        update_user_meta($user_id, 'custom_variable', $custom_variable);

    Hope that solves your problem, Have a great day :slight_smile:

    Thanks and Cheers..!

Thank NAME, for their help.

Let NAME know exactly why they deserved these points.

Gift a custom amount of points.