【发布时间】:2019-05-16 17:52:52
【问题描述】:
我正在尝试将链接项目添加到 WooCommerce 我的帐户菜单中的另一个页面(我的 BuddyPress 页面)。有可能吗?
我看到了这个帖子:How to add external custom url to woocommerce endpoint
但是,我在 BuddyPress 上的页面无法使用,因为它不能用 ULR 写,也不能用 (可能只是我缺乏知识):
add_filter ( 'woocommerce_account_menu_items', 'add_menu_item_to_tabbed_my_account' );
function add_menu_item_to_tabbed_my_account( $menu_links ){
// we will hook "anyuniquetext123" later
$new_item = array( 'anyuniquetext123' => __('Candidate Dashboard') );
// or in case you need 2 links
// $new_item = array( 'link1' => 'Link 1', 'link2' => 'Link 2' );
// 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_item
+ array_slice( $menu_links, 1, NULL, true );
return $menu_links;
}
add_filter( 'woocommerce_get_endpoint_url', 'custom_endpoint_url', 10, 4 );
function custom_endpoint_url( $url, $endpoint, $value, $permalink ){
if( $endpoint === 'anyuniquetext123' ) {
// BuddyPress My page link → <?php echo bp_loggedin_user_domain(); ?>
// I want to make a link of this
// ok, here is the place for your custom URL, it could be external
$url = **'http://alatta.org.ye/candidate-dashboard/';**
}
return $url;
}
其实除了主要的问题,我在改名的时候,还被一个错误困扰。
[更改] '** 候选仪表板 **'-> 'aaa'
[错误信息] 语法错误,意外的 '' (T_STRING)
【问题讨论】:
-
LoaThe Aztec 感谢您的指正。我应该更加小心。对不起。
标签: php wordpress woocommerce endpoint account