LearnDash: Access Mode Column on the Courses Screen
Shows each course's access mode (Open, Free, Buy now, Recurring or Closed) in a column on the Courses list, so you can check pricing at a glance.
Opens WPIDE on
Code
if ( ! defined( 'LEARNDASH_VERSION' ) ) {
return;
}
add_filter( 'manage_sfwd-courses_posts_columns', function ( $columns ) {
$columns['wpide_ld_access'] = 'Access';
return $columns;
} );
add_action( 'manage_sfwd-courses_posts_custom_column', function ( $column, $course_id ) {
if ( 'wpide_ld_access' !== $column ) {
return;
}
$labels = array(
'open' => 'Open',
'free' => 'Free',
'paynow' => 'Buy now',
'subscribe' => 'Recurring',
'closed' => 'Closed',
);
$type = (string) learndash_get_setting( $course_id, 'course_price_type' );
$price = (string) learndash_get_setting( $course_id, 'course_price' );
echo esc_html( ( $labels[ $type ] ?? ucfirst( $type ) ) . ( $price && in_array( $type, array( 'paynow', 'subscribe' ), true ) ? ' (' . $price . ')' : '' ) );
}, 10, 2 );
Notes
Reads the course's own setting; nothing is stored.
How to add this snippet
- Install WPIDE on your WordPress site (it is free) and open Code Snippets.
- Use snippet above adds it from the library in one click. Or copy the code into a new snippet with the same code type.
- It is added inactive: review the code and settings, then switch it on.