woocommerce隱藏會員後台預設登入訊息

WooCommerce-隱藏會員後台預設登入訊息

提供兩種隱藏WooCommerce會員登入訊息的方法。第一種是在function.php中加入程式碼,第二種則是修改dashboard.php檔案。兩種方式都能有效移除不必要的登入提示。

方法一

把下面這一段加在function.php中。

// --- 隱藏會員登入訊息 ---//
add_action( 'woocommerce_account_dashboard', 'disable_please_logout_message' );
function disable_please_logout_message() {
	// Aron 您好 (不是 Aron 嗎? 請登出) ← 隱藏這行訊息
	echo '<style type="text/css">.woocommerce-MyAccount-content{
 		display:none;}</style>';
}


方法二

到woocommerce預設主題資料夾 woocommerce > myaccount > dashboard.php複製,放到自己的佈景主題中並修改。

原本的程式長下面這個樣子

<p><?php
	printf(
		__( 'From your account dashboard you can view your <a href="%1$s">recent orders</a>, manage your <a href="%2$s">shipping and billing addresses</a>, and <a href="%3$s">edit your password and account details</a>.', 'woocommerce' ),
		esc_url( wc_get_endpoint_url( 'orders' ) ),
		esc_url( wc_get_endpoint_url( 'edit-address' ) ),
		esc_url( wc_get_endpoint_url( 'edit-account' ) )
	);
?></p>

把這一段整個註解掉就可以了

<p><?php
	// printf(
	// 	__( 'From your account dashboard you can view your <a href="%1$s">recent orders</a>, manage your <a href="%2$s">shipping and billing addresses</a>, and <a href="%3$s">edit your password and account details</a>.', 'woocommerce' ),
	// 	esc_url( wc_get_endpoint_url( 'orders' ) ),
	// 	esc_url( wc_get_endpoint_url( 'edit-address' ) ),
	// 	esc_url( wc_get_endpoint_url( 'edit-account' ) )
	// );
?></p>


推薦文章

WordPress客製化網頁設計,複製貼上就搞定的程式碼大全

🚀 以每年 5 美元解鎖無廣告體驗

✓ 14 天免費試用 ✓ 隨時取消

在〈WooCommerce-隱藏會員後台預設登入訊息〉中有 47 則留言

發佈留言

發佈留言必須填寫的電子郵件地址不會公開。 必填欄位標示為 *