Enterprise Courses

The Enterprise Courses addon exposes actions and filters that allow you to integrate with group management workflows, extend enterprise pricing, and inject custom logic into enterprise course pages. These hooks are helpful for customizing group membership, permissions, and pricing logic.

Actions

  1. stm_lms_single_course_start

Type: action When it runs: at the top of a single Course page Parameters:

  • $id (int) course ID

Example:

add_action( 'stm_lms_single_course_start', 'stm_lms_single_course_start_function', 10, 1 );
function stm_lms_single_course_start_function( $id ) {
	if ( $id == 22 ) {
		ob_start();
		include plugin_dir_path( __FILE__ ) . '/admin/template/custom-template.php';
		return ob_get_clean();
	}
}
  1. stm_lms_group_updated

Type: action When it runs: when the members list of a group is updated Parameters:

  • $new_emails (array) new member emails

  • $group_id (int) group ID

  • $old_emails (array) previous member emails

Example:

add_action( 'stm_lms_group_updated','stm_lms_group_updated_function', 10, 3 );
function stm_lms_group_updated_function($new_emails, $group_id, $old_emails){
			$response = wp_remote_post(
			'https://demo-website.com/',
			array( 'body' => array(
				'new_emails' => $new_emails,
				'group_id' => $group_id,
				'old_emails' => $old_emails
			)),
		);
		$body     = wp_remote_retrieve_body( $response );

		if ( is_wp_error( $response ) || is_wp_error( $body ) ) {
		$errors[] = 'There was an error occurred after sending a request';
			return $errors;
		}
	
	}
  1. stm_lms_adding_enterprice_groups

Type: action When it runs: when a new member is added to an enterprise group Parameters:

  • $group_id (int) group ID

Example:

add_action( 'stm_lms_adding_enterprice_groups', 'stm_lms_adding_enterprice_groups_function', 10, 1 );
function stm_lms_adding_enterprice_groups_function($group_id){
			$response = wp_remote_post(
			'https://demo-website.com/',
			array( 'body' => array(
				'group_id' => $group_id,
			)),
		);
		$body     = wp_remote_retrieve_body( $response );

		if ( is_wp_error( $response ) || is_wp_error( $body ) ) {
		$errors[] = 'There was an error occurred after sending a request';
			return $errors;
		}
	
	}

Filters

  1. stm_lms_allow_group_manage

Type: filter What it does: controls whether the current user can manage enterprise groups Parameters:

  • $bool (bool) whether group management is allowed

Return: bool

Example:

add_filter( 'stm_lms_allow_group_manage', 'stm_lms_allow_group_manage_function' );
function stm_lms_allow_group_manage_function($bool){
		$user_id = get_current_user_id();

		if($user_id == 4){
			return true;	
		}

		return $bool;
	}
  1. stm_lms_enterprice_price

Type: filter What it does: allows customization of the enterprise course price for a group purchase Parameters:

  • $price (int) original price

  • $item_id (int) course or bundle ID

  • $user_id (int) current user ID

Return: int updated price

Example:

add_filter( 'stm_lms_enterprice_price', 'stm_lms_enterprice_price_function', 10, 3 );
function stm_lms_enterprice_price_function($price, $item_id, $user_id){
		$user_id = get_current_user_id();
		
		if($user_id === 4){
			$price = 100;
		}

		return $price;
	}

Last updated

Was this helpful?