All of the code snippets for modifying existing features can be found below. Check out this linkexternal if you do not know where to add custom code snipeets to your site.

Change Default Order Status For Ofline Payment

add_filter( 'masteriyo_offline_process_payment_order_status', function( $status ) {
    return 'completed';
});

Want to know where and how to add code snippets? Check out this linkexternal

add_filter( 'masteriyo_pro_course_featured_text', function( $text ) {
    return 'New Featured';
});

Want to know where and how to add code snippets? Check out this linkexternal

Sort the courses in the courses page alphabetically by course name.

add_filter( 'pre_get_posts', function ($q) {
	// We only want to affect the main query.
	if ( $q->is_main_query() && is_post_type_archive( 'mto-course' ) ) {
		$q->set( 'orderby', 'title ID');
		$q->set( 'order', 'ASC'); // ASC for A->Z or DESC for Z->A.;
	}
});

Want to know where and how to add code snippets? Check out this linkexternal

Sort the courses in the courses page according to published date.

add_filter( 'pre_get_posts', function ($q) {
	// We only want to affect the main query.
	if ( $q->is_main_query() && is_post_type_archive( 'mto-course' ) ) {
		$q->set( 'orderby', 'date ID');
		$q->set( 'order', 'DESC'); // ASC for Oldest->Newswet or DESC for Newest->Oldest
	}
});

Want to know where and how to add code snippets? Check out this linkexternal

Sort the courses in the courses page according to modified date.

add_filter( 'pre_get_posts', function ($q) {
	// We only want to affect the main query.
	if ( $q->is_main_query() && is_post_type_archive( 'mto-course' ) ) {
		$q->set( 'orderby', 'modified ID');
		$q->set( 'order', 'DESC'); // ASC for Oldest->Newswet or DESC for Newest->Oldest
	}
});

Want to know where and how to add code snippets? Check out this linkexternal

Multiple Coupon code support.

add_filter('masteriyo_enable_multiple_coupon', function($bool, $coupon_code) {
  return true;
});

Want to know where and how to add code snippets? Check out this linkexternal

Solution to Video Playback Fast-Forward or Rewind Function Not Working.

To ensure the security of your self-hosted videos, we provide various security codes. However, in certain cases, the hosting platform may clash with this security measure, making it impossible to forward or rewind the video by clicking on a specific time. In these scenarios, we suggest implementing the code snippet below to resolve the problem.

add_filter( 'masteriyo_self_hosted_lesson_video_url', function( $url, $lesson ) {
	$url = wp_get_attachment_url( $lesson->get_video_source_id() );
	return $url;
}, 10, 2);

Redirect to different page after user/instructor registration.

add_filter( 'masteriyo_registration_redirect_url', function( $url ) {
	return get_permalink( 1 ); // Where 1 is the page/post id.
});

P.S. Currently, you cannot redirect to third-party websites. You can only redirect to the same website page.

Redirect to different page after user/instructor is logged in.

add_filter( 'masteriyo_after_signin_redirect_url', function( $url ) {
	return get_permalink( 1 ); // Where 1 is the page/post id.
});

Want to know where and how to add code snippets? Check out this linkexternal

Redirect to a different page after user/instructor is logged out.

add_filter( 'masteriyo_redirect_logout_url', function($url) {
    $url = 'http://www.google.com';
	// replace http://www.google.com with your redirection link
    return $url;
} );

Want to know where and how to add code snippets? Check out this linkexternal

Change Course Feature Image Size.

add_filter( 'masteriyo_product_get_image', 'modified_img_size', 10, 4 );

function modified_img_size( $image, $course, $size, $attr ) {
if ( $course->get_image_id() ) {
$size = array('400','400'); // Your custom img size here.
$image = wp_get_attachment_image( $course->get_image_id(), $size, false, $attr );
}
return $image;
}

You can change the 400 and 400 image sizes according to your needs. Want to know where and how to add code snippets? Check out this linkexternal


Was this article helpful to you?
Give us Rating

Last edited on March 12, 2025.
Edit this page