admin_options = $options; $this->option_name = $this->admin_options->get_option_name(); } public static function init(Affinidi_Login_Admin_Options $options) { $admin_settings = new self($options); // add_action adds a callback function to an action hook. // admin_init fires as an admin screen or script is being initialized. add_action('admin_init', [$admin_settings, 'admin_init']); // admin_menu fires before the administration menu loads in the admin. // This action is used to add extra submenus and menu options to the admin panel’s menu structure. It runs after the basic admin panel menu structure is in place. add_action('admin_menu', [$admin_settings, 'add_page']); } public function get_admin_settings() { return $this->admin_settings_fields; } /** * [admin_init description] * * @return [type] [description] */ public function admin_init() { // A callback function that sanitizes the option's value register_setting('affinidi_options', $this->option_name, [$this, 'validate']); } /** * Add affinidi submenu page to the settings main menu */ public function add_page() { add_options_page('Affinidi Login', 'Affinidi Login', 'manage_options', 'affinidi_settings', [$this, 'options_do_page']); } /** * [options_do_page description] * * @return [type] [description] */ public function options_do_page() { ?>

Affinidi Login

This plugin is meant to be used with Affinidi Login and uses PKCE extension of OAuth 2.0 standard.

NOTE: If you want to add a custom link anywhere in your theme, simply link to or use the shortcode [affinidi_login] if the user is not logged in.

Step 1: Setup

Create a Login Configuration
  1. Login to Affinidi Portal and go to the Affinidi Login service.
  2. Create a Login Configuration and set the following fields:

    Redirect URIs:

    Auth method: None

  3. Copy the Client ID and Issuer URL and paste it in Step 2 below.
  4. Modify the Presentation Definition and ID Token Mapping using this template.

    If you have activated a supported E-Commerce plugin on this WordPress site, use the template for E-Commerce.

Step 2: Configure

Client ID
Issuer URL

Example: https://[YOUR_PROJECT_ID].apse1.login.affinidi.io

Redirect user to Origin Page admin_options->redirect_user_origin) == 1 ? 'checked="checked"' : ''; ?> />

By default, users will be redirected to Homepage. If the user used the wp-login.php form, they will be redirected to Dashboard.

Restrict user login flow

Signup is currently enabled in the WordPress General Settings.

Update the WordPress settings if you wish to restrict users from signing up using their Vault.

Sign up is currently disabled in the WordPress General Settings.

Update the WordPress settings if you wish to allow users to signup using their Vault.


WooCommerce Settings

Sync customer profile from Vault

Select whether to sync the user profile from Vault whenever the user logs in to their WooCommerce account or only sync their profile on sign-up. Sign-up will populate the customer billing and shipping address info.

Remember to modify the Presentation Definition and ID Token Mapping using the E-Commerce template to request the user profile from Affinidi Vault.

Display Affinidi Login button

If you choose "Use shortcode to display the button", use the shortcode [affinidi_login] and manually edit your desired page to display the button.

Affinidi Login button header (Login Form) admin_options->affinidi_login_loginform_header; echo esc_attr($text_value); ?>"/>

Displays at the top of the Affinidi Login button in the Login Form of WooCommerce.

Affinidi Login button header (Registration Form) admin_options->affinidi_login_regform_header; echo esc_attr($text_value); ?>"/>

Displays at the top of the Affinidi Login button in the Registration Form of WooCommerce.

There's no active supported e-commerce plugin configured on this WordPress site. E-Commerce Settings is disabled. To learn more about the supported e-commerce plugins, click here.

get_admin_settings(); $options = array(); foreach ( $admin_settings as $field ) { if ( isset( $input[ $field ] ) ) { $options[ $field ] = sanitize_text_field( trim( $input[ $field ] ) ); } else { $options[ $field ] = ''; } } return $options; } } $admin_options = new Affinidi_Login_Admin_Options(); Affinidi_Login_Admin_Settings::init($admin_options);