Skip to content

Instantly share code, notes, and snippets.

@shohel
Last active March 9, 2021 08:17
Show Gist options
  • Save shohel/716daff96d9367ab9e928066d430dd1e to your computer and use it in GitHub Desktop.
Save shohel/716daff96d9367ab9e928066d430dd1e to your computer and use it in GitHub Desktop.
This will help you to update / add/ remove the course access method for Dozent LMS, FYI: Dozent LMS is a Modern, Scalable Learning Management System Plugin For WordPress
//Add this code to your course themes/activated-theme/functions.php
// Remove access methods
add_filter( 'dozent_course_access_methods', 'remove_dozent_course_access_methods' );
if ( ! function_exists( 'remove_dozent_course_access_methods' ) ) {
function remove_dozent_course_access_methods( $methods ){
if ( isset( $methods[ 'public' ] ) ) {
unset( $methods[ 'public' ] );
}
if ( isset( $methods[ 'protected' ] ) ) {
unset( $methods[ 'protected' ] );
}
return $methods;
}
}
// Add course methods
add_filter( 'dozent_course_access_methods', 'add_dozent_course_access_methods' );
if ( ! function_exists( 'add_dozent_course_access_methods' ) ) {
function add_dozent_course_access_methods( $methods ){
$methods['extra_method'] = [
'label' => __( 'Extra Method', 'textdomain' ),
'description' => __( 'Extra access method for this course', 'textdomain' ),
'inner_callback' => 'extra_method_callback_function',
//add function and write some html to show when user will select this method
];
return $methods;
}
}
// Edit Course methods lebel or description
add_filter( 'dozent_course_access_methods', 'add_dozent_course_access_methods' );
if ( ! function_exists( 'add_dozent_course_access_methods' ) ) {
function add_dozent_course_access_methods( $methods ){
$methods['protected'][ 'label' ] = __( 'Updated Protected', 'textdomain' );
$methods['protected'][ 'description' ] = __( 'Updated description', 'textdomain' );
return $methods;
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment