Hi @carmpocalypse and @robert681,
Thank you to you both. I really appreciate it. After a few tweaks, I found a way to insert the additional tab on My Account in functions.php
.
I name that tab ‘Security’ and the link will be https://example.com/account/security as their endpoint URL.
Anyone who wants to use this code may rewrite ‘security’ to any term they prefer.
// ADD SECURITY TAB ON MY ACCOUNT
add_action( 'init', 'register_security_endpoint');
/**
* Register New Endpoint.
*
* @return void.
*/
function register_security_endpoint() {
add_rewrite_endpoint( 'security', EP_ROOT | EP_PAGES );
}
add_filter( 'query_vars', 'security_query_vars' );
/**
* Add new query var.
*
* @param array $vars vars.
*
* @return array An array of items.
*/
function security_query_vars( $vars ) {
$vars[] = 'security';
return $vars;
}
add_filter( 'woocommerce_account_menu_items', 'add_security_tab' );
/**
* Add Security tab in my account page.
*
* @param array $items myaccount Items.
*
* @return array Items including New tab.
*/
function add_security_tab( $items ) {
$items['security'] = 'Security';
return $items;
}
add_action( 'woocommerce_account_security_endpoint', 'add_security_content' );
/**
* Add content to the Security tab.
*
* @return string.
*/
function add_security_content() {
echo "<h1>Security</h1>";
echo 'With two-factor authentication, also called 2-Step Verification, you can add an extra layer of security to your account in case your password is stolen. After you set up two-factor authentication, you can sign in to your account with your password and your phone.';
echo do_shortcode('[wp-2fa-setup-form show_preamble="false"]');
}
-
This reply was modified 2 years ago by Kawah Buku.