Skip to content

Instantly share code, notes, and snippets.

@gsibert
Forked from danielmcclure/functions.php
Last active February 25, 2021 06:37
Show Gist options
  • Star 1 You must be signed in to star a gist
  • Fork 1 You must be signed in to fork a gist
  • Save gsibert/52559173c0e5b545d4e4589eab35a61c to your computer and use it in GitHub Desktop.
Save gsibert/52559173c0e5b545d4e4589eab35a61c to your computer and use it in GitHub Desktop.
Add LearnDash Enrolled Courses Grid to My Account Tab in WooCommerce
/* 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