Support » Plugin: Simple Facebook Connect » Simple Facebook Connect add oAuth Variables – birthday

Viewing 7 replies - 1 through 7 (of 7 total)
  • Plugin Author Samuel Wood (Otto)

    (@otto42)

    WordPress.org Admin

    There was no good way to do this before, but I just added the necessary hook to the trunk code, so here’s how you can do it with that code.

    First, you need to add the birthday field to the registration form. You’d do that like so:

    add_filter('sfc_register_fields','add_birthday');
    function add_birthday($fields) {
      $fields[] = array('name'=>'birthday');
      return $fields;
    }

    That adds the birthday field. You can also add ‘view’=>’prefilled’ to that array to make it only show up for people registering with FB credentials and not to people registering without them.

    Next, you need to get the birthday information and save it somewhere when they submit the form. I added the sfc_register_request action to allow for that.

    add_action('sfc_register_request','get_birthday');
    function get_birthday($info) {
      global $saved_birthday;
      if (!empty($info['birthday'])) $saved_birthday = $info['birthday'];
    }

    Finally, you need to save the birthday with the user’s account somehow. SFC’s register function doesn’t actually create users, it lets WordPress do that normally. So you can hook into the normal WP user_register hook to take the necessary action.

    add_action('user_register','save_birthday');
    function save_birthday($userid) {
      global $saved_birthday;
      if ($userid && !empty($saved_birthday) ) {
        update_usermeta($userid, 'birthday', $saved_birthday);
      }
    }

    Something similar to that will do the job.

    Hey Otto,

    Thanks so much for this excellent plugin. I need to add fields and validation to the registration form to confirm that users are over the age of 13 but have not been able to get this working on WP 3.3, using the latest version of SWC.

    The code above is not working to add the fields. This should be done in sfc-register.php, correct? I added the actions and fields after the functions but still no dice.

    Plugin Author Samuel Wood (Otto)

    (@otto42)

    WordPress.org Admin

    No, that code should not be in sfc-register.php. It should be in your own plugin or theme’s functions.php code.

    Hey Otto ~

    Would it be possible to use the same approach to store the auth token?

    Cheers

    Plugin Author Samuel Wood (Otto)

    (@otto42)

    WordPress.org Admin

    The auth token is already stored as part of the usermeta on login.

    Okay great. Buying you a beer dude!

    Hi Otto: Thanks for the cool plugin.

    I am calling your code in a script this way:

    $fb_graphdata = sfc_remote($fb_cookie['user_id'], '', $fb_args_array, 'GET');

    Where $fb_args_array is a list (just name and email). Can I add user_birthday to this query somehow? I’ve been having trouble requesting that data in tandem with your code when used in this way.

    Thank you!

Viewing 7 replies - 1 through 7 (of 7 total)
  • The topic ‘Simple Facebook Connect add oAuth Variables – birthday’ is closed to new replies.