开发者 | idandtrust |
---|---|
更新时间 | 2019年5月7日 23:48 |
PHP版本: | 5.6 及以上 |
WordPress版本: | 5.2 |
版权: | MIT License |
版权网址: | 版权信息 |
size
: The supported values are: small
, default
, large
claimset
: You can set the ID of the claimset that you want to use.
For example:
[goodid_login_button size="large"]
"email": {"essential": true}, "email_verified": {"value": true}
as requesting a verified e-mail address is necessary for the wordpress plugin.
The value of the essential parameter defines whether filling the claim is required or optional.
The following is a short example:
{ "id_token": {}, "userinfo": { "email": { "essential": true }, "email_verified": { "value": true }, "family_name": { "essential": false }, "middle_name": { "essential": false }, "given_name": { "essential": false }, "billto.company_name": { "essential": false } } }
A default claimset is included in the plugin as default-claims.json.
The list of all supported claims can be found here: http://goodid.s3.amazonaws.com/manual/3.+GoodID+Scopes+and+claims.pdf
The Mapping setting defines the mapping between the requested claims and the WordPress or WooCommerce fields.
The user_email field must not be mapped in the mapping, because it is automatically handled by the plugin.
This is a short example:
{ "wordpress": { "first_name": [ "concatenate", "middle_name", "given_name" ], "last_name": "family_name" }, "woocommerce": { "billing_company_name": "billto.company_name" } }
The mapping is divided into groups for clarity.
If you have any other plugin which handles custom data about the user, you can also map that data from GoodID in a new group. You can name a group anything.
A single mapping item uses one of the following formats:
`
1.
"wordpress_field_name": "goodid_claim_name"
"wordpress_field_name": [
"concatenate",
"goodid_claim_name1",
"goodid_claim_name2",
...
]
"shipping_state": [
"get_wc_region",
"address.country_code_iso_2",
"address.region"
]
"billing_state": [
"get_wc_region",
"billto.address.country_code_iso_2",
"billto.address.region"
]
`
The first version is the easiest, it means mapping a single GoodID claim to a single WordPress (or any plugin) field.
With more mapping items, you can map a single GoodID claim to any number of WordPress fields, but a WordPress field must have only one mapping. If a GoodID claim is optional and not filled by the user, mappings which refer to it have no effect.
The second version maps the concatenation of any number of GoodID claims to a WordPress field. The claims that are filled by the user are separated by a space. If no claim is filled by the user, then the mapping has no effect.
The 3rd and 4th version describes a mapping between GoodID address data and WooCommerce state. The special syntax is needed because WooCommerce uses a special state code which we have to calculate from a country code and a region.
A default mapping is included in the plugin as default-mapping.json.$goodidUser = new GoodID_WP_User(new GoodID_WP_Settings()); $claims = $goodidUser->getClaims(); $mappedBillingFirstName = $goodidUser->getDataByMapping(null, 'billing_first_name');
$goodidUser = new GoodID_WP_User(new GoodID_WP_Settings()); $goodidUser->logout();
` $goodidPassData = new GoodID_WP_Pass_Data(new GoodID_WP_Settings()); $entitledUsers = $goodidPassData->get(11); if ($entitledUsers) { foreach ($entitledUsers->get() as $entitledUser) { if ($entitledUser->hasDownloaded()) { // Downloaded the pass } } } `
` $goodidPassData = new GoodID_WP_Pass_Data(new GoodID_WP_Settings()); $entitledUsers = $goodidPassData->get(11); if ($entitledUsers) { foreach ($entitledUsers->get() as $entitledUser) { if ($entitledUser->hasUsed()) { // The user visited the event } } } `
$goodidProductSettingHelper = new GoodID_WP_ProductSettingHelper(new GoodID_WP_Settings()); $goodidProductSettingHelper->saveEventSettings(...);
// if the user is not registered $entitledGoodidGuest->reAssign('John Doe', 'john.doe@example.com'); // or if the user is registered $entitledGoodidUser->reAssign($newUserId);
If you want to know more, please visit https://goodid.net