1. Home
  2. Docs
  3. Tutorials
  4. Editing Course Access Method

Editing Course Access Method

Editing Course Access Method

At Dozent LMS WordPress Plugin, we believe in empowering our users to the fullest. We also think about the developer community. Hence, we are offering the system of editing course access methods so that you can alter the currently available methods and make a method as you prefer. The following codes will help you add/remove/update course access methods for Dozent LMS. Add these codes to your course themes, activated themes, or functions.php to accomplish the task.

Note: Add these codes to your child theme’s functions.php file or use a plugin that allows you to add custom functions. If you add these codes to the parent theme’s functions.php file, it will be completely erased when you update the theme.

Remove access methods

To remove an access method, use this snippet:

// 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

To add a new course access method, use the following snippet:

// 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 method’s label or description

To edit the label or description of your course access method, use this snippet:

// Edit Course methods label or description

add_filter( 'dozent_course_access_methods', 'edit_dozent_course_access_methods', 99 );
if ( ! function_exists( 'edit_dozent_course_access_methods' ) ) {
	function edit_dozent_course_access_methods( $methods ){
		//Where 'closed' is your course access method's key

		$methods['closed'][ 'label' ] = __( 'Updated Label', 'textdomain' );
		$methods['closed'][ 'description' ] = __( 'Updated Description', 'textdomain' );

		return $methods;
	}
}

With these snippets, you can easily edit, add, and/or remove access methods for all your Dozent LMS courses.

Was this article helpful to you? Yes No

How can we help?