Created
August 16, 2020 18:42
-
-
Save MrThiemann/f5fec343e1d65d9a1fecc8361b399e8d to your computer and use it in GitHub Desktop.
Vendor Settings
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?php | |
/* | |
* Step 1. Add Link (Tab) to My Account menu | |
*/ | |
add_filter ( 'woocommerce_account_menu_items', 'misha_vendor_details_link', 40 ); | |
function misha_vendor_details_link( $menu_links ){ | |
$menu_links = array_slice( $menu_links, 0, 5, true ) | |
+ array( 'vendor-settings' => 'Verkäufer Einstellungen' ) | |
+ array_slice( $menu_links, 5, NULL, true ); | |
return $menu_links; | |
} | |
/* | |
* Step 2. Register Permalink Endpoint | |
*/ | |
add_action( 'init', 'misha_add_endpoint' ); | |
function misha_add_endpoint() { | |
// WP_Rewrite is my Achilles' heel, so please do not ask me for detailed explanation | |
add_rewrite_endpoint( 'vendor-settings', EP_PAGES ); | |
} | |
/* | |
* Step 3. Content for the new page in My Account, woocommerce_account_{ENDPOINT NAME}_endpoint | |
*/ | |
add_action( 'woocommerce_account_vendor-settings_endpoint', 'misha_my_account_endpoint_content' ); | |
function misha_my_account_endpoint_content() { | |
// of course you can print dynamic content here, one of the most useful functions here is get_current_user_id() | |
echo '<h3>Hier können in Zukunft Angaben zu euren Dienstleistungen vorgenommen werden</h3>'; | |
} | |
/* | |
* Step 4 | |
*/ | |
// Go to Settings > Permalinks and just push "Save Changes" button. | |
?> |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment