Synchronize Microsoft 365 / Azure AD profile fields
Use this guide if you want to synchronize additional Microsoft 365 / Azure AD profile fields e.g. job title, department or employee number to WordPress / BuddyPress. This is a one-way synchronization that will pull the latest values from Microsoft 365 / Azure AD when the user logs into WordPress. Any values that were updated in WordPress will not be pushed back into Microsoft 365 / Azure AD.
Before you start
- You must already have configured the single sign-on capability of the WordPress + Office 365 plugin.
- You must also have configured the integration capability of the plugin.
- You are a Global Administrator for your company’s Office 365 tenant / Azure AD directory (or have at least the ability to edit the Azure Active Directory App registration that was created previously when the single sign-on capability was configured).
- You are an Administrator for your WordPress website.
- To go to the App registration in Azure AD, navigate to WP Admin > WPO365 > Single sign-on and click the link View in Azure Portal for the Application (client) ID.
- A new browser tab opens and loads the App registration in Azure AD.
- Switch to the newly opened tab and to edit the permissions of the App registration.
- Click API permissions from the 'App registration' menu on the left
- Click + Add permission.
- Select Microsoft Graph > Delegated permissions.
- Scroll down to Users and check
Click Add permissions.
- Wait until Grant admin consent for … has become available, then click to grant consent for all users in your tenant to use these permissions when they sign into this app.
- Switch back to the previous tab and the plugin's configuration pages.
- Go WP Admin > WPO365 > User sync.
- Scroll down to Azure AD user attribute to WordPress user meta mappings and per row enter first the technical name for the field you want to retrieve e.g. jobTitle, mobilePhone or officeLocation followed by the title that is be used when the field is shown in the user’s profile e.g. Job title, Mobile phone or Office location. Make sure to click “+” each time after you entered a new combined field.
See the online documentation of Microsoft Graph's User Resource for a list of available properties. Please note that you can optionally change the Microsoft Graph version to beta and that the beta version by default will return more properties e.g. department .
Also note that Microsoft Graph properties always start with a lowercase character e.g. department (and not Department).
If you need to retrieve properties that are not returned by Microsoft Graph by default then you must explicitly define additional $select properties.
Starting from v17.0 the plugin will always attempt to synchronize the mapped fields in this list. For older version you needed to check the option to Show Azure AD user attributes in a WordPress user profile (show O365 user profile fields).
Show Azure AD user attributes in a WordPress user profile
Checking the option to Show Azure AD user attributes in a WordPress user profile will add a new section labeled Office 365 Profile Information to a user's WordPress profile and display the fields as shown in the following
Retrieving array / child properties
Sometimes you may want to reference complex user profile properties when synchronizing WordPress user profiles with Microsoft Graph e.g. the first entry of the array of businessPhones or the sub property extensionAttribute1 of user profile property onPremisesExtensionAttributes. To achieve that you can write businessPhones.0 (to retrieve the first business phone of an array of possible entries by using the zero based array indexer) or onPremisesExtensionAttributes.extensionAttribute1 (to retrieve a named child property).
Developers can retrieve this user meta in the familiar way using get_user_meta where the key that is used corresponds to the Microsoft Graph User Resource property name e.g.
get_user_meta( get_current_user_id(), 'jobTitle', true );
When using BuddyPress it is possible to update the so-called extended fields (see https://docs.wpo365.com/article/73-update-matching-buddypress-extended-profile-fields for details).