You are currently viewing Woocommerce Hack! Add New Menu in Dashboard.

Woocommerce Hack! Tambah Menu Batu di Dashboard.

Anda ada page private untuk pelanggan atau pengguna?

Ingin link kan page tersebut di dashboard pengguna di my account Woocommerce?

Gunakan kod ini di:

(Bagaimana letak kod? Baca Hack Woocommerce! Tambah content di My Account.)

//add new menu at woocommerce my account dashboard

add_filter ( 'woocommerce_account_menu_items', 'xhanxeli_one_more_link' );
function xhanxeli_one_more_link( $menu_links ){
    
	$new = array( 'newmenu' => 'YOUR MENU NAME' );
 
	// array_slice() is good when you want to add an element between the other ones
	$menu_links = array_slice( $menu_links, 0, 1, true ) 
	+ $new 
	+ array_slice( $menu_links, 1, NULL, true );
 
 
	return $menu_links;
 
 
}
 
add_filter( 'woocommerce_get_endpoint_url', 'xhanxeli_hook_endpoint', 10, 4 );
function xhanxeli_hook_endpoint( $url, $endpoint, $value, $permalink ){
 
	if( $endpoint === 'newmenu' ) {
 
		// ok, here is the place for your custom URL, it could be external
		$url = site_url('YOUR URL');
 
	}
	return $url;
 
}

Tukar sahaja YOUR MENU NAME kepada nama menu anda dan tukar YOUR URL kepada url luar atau page anda.

Beritahu saya jika kod ni tak berfungsi!

Selamat mencuba.

Han

Web Designer, Web Developer, Digital Marketer, Penulis Artikel & Seorang Blogger. Pentadbir laman web Xhanxeli Network.
Disclaimer: The opinions expressed on this website; enteries and in the comments section, are not necessarily those of xhanxeli.com, it's advertisers, or anyone else displayed on this website.

Tinggalkan Komen