-
-
Save gsibert/52559173c0e5b545d4e4589eab35a61c to your computer and use it in GitHub Desktop.
Add LearnDash Enrolled Courses Grid to My Account Tab in WooCommerce
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
/* Add LearnDash Profile to My Account Tab in WooCommerce */ | |
/* Add Courses Link to My Account menu */ | |
add_filter ( 'woocommerce_account_menu_items', 'wc_ld_link', 40 ); | |
function wc_ld_link( $menu_links ){ | |
$menu_links = array_slice( $menu_links, 0, 5, true ) | |
+ array( 'courses' => 'My Courses' ) | |
+ array_slice( $menu_links, 5, NULL, true ); | |
return $menu_links; | |
} | |
/* Add Courses Permalink Endpoint */ | |
add_action( 'init', 'wc_ld_endpoint' ); | |
function wc_ld_endpoint() { | |
add_rewrite_endpoint( 'courses', EP_PAGES ); | |
} | |
/* Add Content to Endpoint */ | |
add_action( 'woocommerce_account_courses_endpoint', 'learndash_my_account_endpoint_content' ); | |
function learndash_my_account_endpoint_content() { | |
// Add Course Grid Scripts & Styles | |
// LearnDash Profile | |
echo do_shortcode( '[ld_profile orderby="title" order="ASC" show_header="false"]' ); | |
} | |
//Reorder Menu | |
function my_account_menu_order() { | |
$menuOrder = array( | |
'dashboard' => __( 'Dashboard', 'woocommerce' ), | |
'courses' => __( 'My Courses', 'woocommerce' ), | |
'orders' => __( 'Orders', 'woocommerce' ), | |
'downloads' => __( 'Download', 'woocommerce' ), | |
'edit-address' => __( 'Addresses', 'woocommerce' ), | |
'edit-account' => __( 'Account Details', 'woocommerce' ), | |
'customer-logout' => __( 'Logout', 'woocommerce' ), | |
); | |
return $menuOrder; | |
} | |
add_filter ( 'woocommerce_account_menu_items', 'my_account_menu_order' ); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment