Here is my attempt to bring Two-Factor settings to front-end (thus becoming available for WooCommerce users to see):
Edited class-two-factor-core.php
: following WordPress hooks (edit_user_profile
and edit_user_profile_update
) I have used corresponding functions in WooCommerce hooks:
add_action( 'woocommerce_edit_account_form', array( __CLASS__, 'user_two_factor_options' ) );
add_action( 'woocommerce_update_customer', array( __CLASS__, 'user_two_factor_options_update' ) );
Edit part worked fine – settings were saved. However, form was broken: in the end of function user_two_factor_options
there is do_action( 'show_user_security_settings', $user );
which in the frontend exited further rendering of page. So I created a copy of user_two_factor_options
function and commented that code out – in this case form was rendered nicely in WooCommerce’s my-account/edit-account
page.
However, JavaScripts didn’t work – I couldn’t see QR code nor any other JavaScript-based elements. Any tips on that? Perhaps something is reused from wp-admin
components that are not available on frontend?