summaryrefslogtreecommitdiff
path: root/snippets/oidc-reclaim.php
blob: cbb2f8c857b2d718e0918315650a2bf942797d7a (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
/**
 * This snipped integrates the OIDC connect button with WooCommerce
 * to allow importing the customer's shopping details via OIDC / Re:ClaimID
 */

// Modify OIDC connect button text for Reclaim:ID
add_filter('openid-connect-generic-login-button-text', function( $text ) {
    $text = __('Login with Re:ClaimID', 'gnutaler' );
    return $text;
});

// make sure OIDC 'login' goes to WooCommerce checkout URL.
add_action('openid-connect-generic-redirect-user-back',
    function( $redirect_url, $user ) {
      // Take over the redirection complete.
      // Send users somewhere special based on their capabilities.
      global $woocommerce;
      $checkout_url = $woocommerce->cart->wc_get_checkout_url ();
      wp_redirect( $checkout_url); // or admin_url( $checkout_url) )?;
      exit();
   },
   10,
   2);