@@ -37,6 +37,7 @@ Much of the documentation can be found on the Settings > OpenID Connect Generic
3737 - [ openid-connect-generic-user-update] ( #openid-connect-generic-user-update )
3838 - [ openid-connect-generic-update-user-using-current-claim] ( #openid-connect-generic-update-user-using-current-claim )
3939 - [ openid-connect-generic-redirect-user-back] ( #openid-connect-generic-redirect-user-back )
40+ - [ openid-connect-generic-register-login-form] ( #openid-connect-generic-register-login-form )
4041
4142
4243## Installation
@@ -366,6 +367,38 @@ add_action('openid-connect-generic-redirect-user-back', function( $redirect_url,
366367}, 10, 2);
367368```
368369
370+
371+ #### ` openid-connect-generic-register-login-form `
372+
373+ Allow user to add the login form to various pages, such as WooCommerce's checkout page. It will fire
374+ whenever the plugin is loaded and pass the login form to the callback.
375+
376+ Provides 1 argument: the login form instance.
377+
378+ ```
379+ add_action ('openid-connect-generic-register-login-form',
380+ function ( $login_form ) {
381+
382+ // show login form at the shopping cart (if not logged in)
383+ add_action( 'woocommerce_before_checkout_billing_form',
384+ function () use ( $login_form ) {
385+ $user = wp_get_current_user ();
386+ if (0 == $user->ID) {
387+ // ID 0 is used to indicate user is not logged in.
388+ // Re-use filter logic to generate login page
389+ print ( $login_form->handle_login_page ('') );
390+ }
391+ });
392+
393+ // Add action to set cookie to redirect back to current
394+ // (checkout) page after OIDC provided the data
395+ add_action( 'woocommerce_before_checkout_billing_form',
396+ array( $login_form, 'handle_redirect_cookie' ) );
397+
398+ }
399+ );
400+ ```
401+
369402### User Meta Data
370403
371404This plugin stores meta data about the user for both practical and debugging purposes.
0 commit comments