Extending OpenID
Submitted Collin S. , Mar 19 2011 12:20 PM | Last updated Jan 12 2012 06:51 AM
Extending OpenID
IP.Board includes support for OpenID. By default IP.Board will require only the user's EMail address, but will also ask for "nickname" and date of birth, and use these if provided.
You can extend on this to include other information from the user's OpenID provider. In this example, we'll extend IP.Board to use the user's gender from their OpenID profile if it's available, and set it in IP.Board - you can modify the specifics to handle whatever data you wish to get from OpenID.
First, it's important that you configure IP.Board to accept this new information. You can do this from the Log In Management section of the System tab in your ACP.
Choose "Configure Details..." for the OpenID method.
Add the field you want to either the optional or required arguments to pull. The field must be supported by the OpenID provider. For a list of supported fields, see the OpenID specs.
So in our example, our "Optional args to pull" (since we want the gender to be optional) now reads "nickname,dob,gender".
So now, when we log in, our OpenID provider will now provide IP.Board with our gender.

We now need to modify IP.Board to actually set this in our profile. All of the OpenID authentication code is in admin/sources/loginauth/openid/auth.php. We'll need to change the code to support both creating a new member, and updating an existing member.
The code for creating a new member is:
We'll need to add into that array the gender. The gender in IP.Board is stored in a custom profile field. On my installation, it has the ID number of 5. So here is what we'll change that to:
The reason for the strtolower is that OpenID sends back either "M" or "F", whereas IP.Board stores the gender as "m" or "f". You may need to manipulate the data you get from OpenID to make it appropriate for IP.Board in a similar manner.
The code for updating a member signing in with OpenID is:
So we'll change this too to accommodate our extra information:
And that's all that's needed, now when you sign in with your OpenID information, the extra information will have been applied.
IP.Board includes support for OpenID. By default IP.Board will require only the user's EMail address, but will also ask for "nickname" and date of birth, and use these if provided.
You can extend on this to include other information from the user's OpenID provider. In this example, we'll extend IP.Board to use the user's gender from their OpenID profile if it's available, and set it in IP.Board - you can modify the specifics to handle whatever data you wish to get from OpenID.
First, it's important that you configure IP.Board to accept this new information. You can do this from the Log In Management section of the System tab in your ACP.
Choose "Configure Details..." for the OpenID method.
Add the field you want to either the optional or required arguments to pull. The field must be supported by the OpenID provider. For a list of supported fields, see the OpenID specs.
So in our example, our "Optional args to pull" (since we want the gender to be optional) now reads "nickname,dob,gender".
So now, when we log in, our OpenID provider will now provide IP.Board with our gender.
We now need to modify IP.Board to actually set this in our profile. All of the OpenID authentication code is in admin/sources/loginauth/openid/auth.php. We'll need to change the code to support both creating a new member, and updating an existing member.
The code for creating a new member is:
$this->member_data = $this->createLocalMember( array( 'members' => array( 'email' => $email, 'name' => $name, 'members_l_username' => strtolower($name), 'members_display_name' => $name, 'members_l_display_name' => strtolower($name), 'joined' => time(), 'bday_day' => $bday_day, 'bday_month' => $bday_mon, 'bday_year' => $bday_year, 'members_created_remote' => 1, 'identity_url' => $this->data_store['fullurl'], ), 'profile_portal' => array( ), ) );
We'll need to add into that array the gender. The gender in IP.Board is stored in a custom profile field. On my installation, it has the ID number of 5. So here is what we'll change that to:
$this->member_data = $this->createLocalMember( array( 'members' => array( 'email' => $email, 'name' => $name, 'members_l_username' => strtolower($name), 'members_display_name' => $name, 'members_l_display_name' => strtolower($name), 'joined' => time(), 'bday_day' => $bday_day, 'bday_month' => $bday_mon, 'bday_year' => $bday_year, 'members_created_remote' => 1, 'identity_url' => $this->data_store['fullurl'], ), 'profile_portal' => array( ), 'pfields_content' => array( 'field_5' => strtolower( $this->data_store['gender'] ), ), ) );
The reason for the strtolower is that OpenID sends back either "M" or "F", whereas IP.Board stores the gender as "m" or "f". You may need to manipulate the data you get from OpenID to make it appropriate for IP.Board in a similar manner.
The code for updating a member signing in with OpenID is:
IPSMember::save( $this->member_data['email'], array( 'core' => $core ) );
So we'll change this too to accommodate our extra information:
IPSMember::save( $this->member_data['email'], array( 'core' => $core, 'pfields_content' => array( 'field_5' => strtolower( $this->data_store['gender'] ) ) ) );
And that's all that's needed, now when you sign in with your OpenID information, the extra information will have been applied.











0 Comments