Simple way to add a new tag on woocomerce’s \
Myaccount woocomer page menu working mode these tabs of woocomer are menus by default. You can filter the content of the page, import the array of displayed menus, and then add content to the array and return content. If you’ve never used a filter before hooking a woocomer \/ WordPress filter, we’ve written a detailed introduction to the filter in apply_filters and do_action in this tutorial. Another good example is the filter applied to _contentbefore and after the default word press post or page content to add content.
The information about filter hooking is enough. Now we will focus on how to add the menu to woocommerce’s \
To create a filter hook and add a new label to the my account page, the filter must collect all the data displayed on the menu and then push the new data. (remember the word push, which I will describe in more detail later in this post) create a second filter on the generated page and add the URL redirection of the menu added in the first step to the generated page. This code is a function of the topic. If you add it to a PHP file or add it to a plug-in class or function, the new menu will be successfully added to the \
In this tutorial, you must assume that this is true, add the menu to the my account page and redirect it to the forum. First, the image below shows the final product of adding a new tag on the \
function example_forum_link( $menu_links ){
\/\/Connect \
$new = array (\
\/\/Or two links are required
\/\/$new = array (\
\/\/ arra
Ray_slice() is used to add elements between other elements.
$menu_links = array_slice( $menu_links, 0, 1, true )
+$NEW
+ array_slice( $menu_links, 1, NULL, true );
Return $menu_links;
}
add_filter ( ‘woocommerce_account_menu_items’, ‘example_forum_link’ );
\/\/The woocommerce endpoint redirects to the second filter of the custom URL
function forum_example_hook_endpoint( $url, $endpoint, $value, $permalink ){
If ($endpoint = = \
\/\/This is where you add custom URLs. In this case, you may need to be external, just like moving to my profile of bbpress Fromm.
\/\/This function (bp_core_get_username (bp_loggedin_user_id());) Use to get the profile User ID and add it to the URL, as follows:
$url = site_url() .’\/ Member \/ \
}
Return $URL;
}
add_filter( ‘woocommerce_get_endpoint_url’, ‘forum_example_hook_endpoint’, 10, 4 );
Finally, after reading this tutorial, it will not be difficult to create a new menu tab on woocommerce’s my account page. We’ll add a new tab to the my account page and follow the steps to create a practical example of how to use the selected page to create a redirect. We have also written other tutorials on how to add woocommerce redirection after checkout and how to add woocommerce redirection after registration. If this solution cannot be implemented, you can seek the help of professional woocommerce developers.