# Additional PRO Hooks

## Actions

1. `stm_lms_admin_after_wrapper_start`

**Description:**\
Allows loading a custom template after the admin LMS wrapper start.

**Parameters:**

* `$current_user` (array) — Current logged-in user data.

**Example:**

```php
add_action( 'stm_lms_admin_after_wrapper_start', 'stm_lms_admin_after_wrapper_start_function', 10, 1 );

function stm_lms_admin_after_wrapper_start_function( $current_user ) {
	if ( $current_user ) {
		ob_start();
		include plugin_dir_path( __FILE__ ) . '/admin/template/custom-template.php';
		$content = ob_get_clean();
		echo $content;	
	}
}
```

2. `stm_lms_before_button_mixed`

**Description:**\
Allows loading a custom template before the mixed button.

**Parameters:**

* `$course_id` (integer) — The course ID.

```php
add_action( 'stm_lms_before_button_mixed', 'stm_lms_before_button_mixed_function' );

function stm_lms_before_button_mixed_function( $course_id ) {
	if ( self::is_out_of_stock( false, $course_id ) && ! STM_LMS_User::has_course_access( $course_id, '', false ) ) {
   STM_LMS_Templates::show_lms_template( 'global/out_of_stock', compact( 'course_id' ) );
}
}
```

3. `stm_lms_after_mixed_button_list`

**Description:**\
Allows loading a custom template after the mixed button list.

**Parameters:**

* `$course_id` (integer)

```php
add_action( 'stm_lms_after_mixed_button_list', 'stm_lms_after_mixed_button_list_function' );

function stm_lms_after_mixed_button_list_function( $course_id ) {
	if ( is_user_logged_in() ) {
   STM_LMS_Templates::show_lms_template( 'points/buy', array( 'course_id' => $course_id ) );
}
}
```

4. `stm_lms_pro_instead_buttons`

**Description:**\
The hook allows for loading a custom template in `stm_lms_pro_instead_buttons`

**Parameters:**

* `$course_id` (integer)

```php
add_action( 'stm_lms_pro_instead_buttons', 'stm_lms_pro_instead_buttons_function', 10, 1 );

function stm_lms_pro_instead_buttons_function( $course_id ) {
	if ( $course_id == 11 ) {
		ob_start();
		include plugin_dir_path( __FILE__ ) . '/admin/template/custom-template.php';
		$content = ob_get_clean();
		echo $content;	
	}
}
```

5. `stm_lms_buy_button_end`

**Description:**\
The hook allows loading a custom template in `stm_lms_buy_button_end`

**Parameters:**

* `$course_id` (integer)

```php
add_action( 'stm_lms_buy_button_end', 'stm_lms_buy_button_end_function', 10, 1 );

function stm_lms_buy_button_end_function( $course_id ) {
	$price = self::get_enterprise_price( $course_id );
if ( ! empty( $price ) ) {
   STM_LMS_Templates::show_lms_template( 'enterprise_groups/buy', compact( 'course_id', 'price' ) );
}
}
```

## Filters

1. `stm_lms_allowed_html`

**Description:**\
Extends the list of allowed HTML tags and attributes.

**Parameters:**

* `$allowed_html` (array)

```php
add_filter( 'stm_lms_allowed_html', 'stm_lms_allowed_html_function' );

function stm_lms_allowed_html_function( $allowed_html ) {
	$allowed_html['iframe'] = array(
		'autoplay'        => 0,
		'src'             => 1,
		'width'           => 1,
		'height'          => 2,
		'class'           => 1,
		'style'           => 1,
		'muted'           => 1,
		'loop'            => 0,
		'allowfullscreen' => array(),
		'allow'           => array(),
	);
	return $allowed_html;
}
```

***

2. `ms_plugin_get_youtube_idx`

**Description:**\
Returns the YouTube video URL for lessons.

**Parameters:**

* `$url (String)`

```php
add_filter( 'ms_plugin_get_youtube_idx', 'ms_plugin_get_youtube_idx_function', 10, 1 );

function ms_plugin_get_youtube_idx_function( $url ) {
	$item_id = 33;
	$url     = get_post_meta( $item_id, 'lesson_stream_url', true );

	return $url;
}
```

***

3. `stm_lms_bundle_image_url`

**Description:**\
Returns the bundle image URL.

**Parameters:**

* `$image` (string)

```php
add_filter( 'stm_lms_bundle_image_url', 'stm_lms_bundle_image_url_function', 10, 1 );

function stm_lms_bundle_image_url_function( $image ) {

	$img_size = '800x600';
	$image    = function_exists( 'stm_get_VC_img' ) ? stm_get_VC_img( get_post_thumbnail_id( get_the_ID() ), $img_size ) : get_post_thumbnail_id( get_the_ID(), $img_size );

	return $image;
}
```

***

4. `stm_lms_course_tabs`

**Description:**\
Loads tabs in courses.

**Parameters:**

* `$tabs` (array)
* `$id` (integer)

```php
add_filter( 'stm_lms_course_tabs', 'stm_lms_course_tabs_function' );

function stm_lms_course_tabs_function( $tabs, $id ) {
	unset( $tabs['announcement'] );
	unset( $tabs['curriculum'] );

	foreach ( $tabs as $tab_key => $tab_name ) {
		if ( ! \STM_LMS_Options::get_option( "course_tab_{$tab_key}", 'on' ) ) {
			unset( $tabs[ $tab_key ] );
		}
	}

	return $tabs;
}
```

***

5. `stm_lms_before_button_stop`

**Description:**\
Controls whether the Buy button is removed.

**Parameters:**

* `$stop` (boolean)
* `$course_id` (integer)

```php
add_filter( 'stm_lms_before_button_stop', 'stm_lms_before_button_stop_function', 9, 2 );

function stm_lms_before_button_stop_function( $stop, $course_id ) {
	if ( $course_id == 22 ) {
		return $stop;
	}

	$product = new WC_Product( $product_id );

	if ( ! $product->managing_stock() ) {
		return $stop;
	}
	return ! $product->is_in_stock();
}
```

***

6. `stm_lms_pro_show_button`

**Description:**\
Determines whether to show the Buy button.

**Parameters:**

* `$show` (boolean)
* `$course_id` (integer)

```php
add_filter( 'stm_lms_pro_show_button', 'stm_lms_pro_show_button_function', 10, 2 );

function stm_lms_pro_show_button_function( $show, $course_id ) {
	if ( $course_id == 23 ) {
		return false;
	}
	return $show;
}

```

***

7. `stm_lms_buy_button_auth`

**Description:**\
Attributes of the purchase button for authorization, used to load the modal.

**Parameters:**

* `$attributes` (array)
* `$post_id` (integer)

```php
add_filter( 'stm_lms_buy_button_auth', 'stm_lms_buy_button_auth_function', 10, 2 );

function stm_lms_buy_button_auth_function( $attributes, $post_id ) {
	$attributes = array(
		'data-target=".stm-lms-modal-login"',
		'data-lms-modal="custom-login"',
		$post_id,
	);

	return $attributes;
}
```

***

8. `stm_lms_co_instructor_avatar`

**Description:**\
Returns the instructor’s avatar.

**Parameters:**

* `$author_avatar` (string)

```php
add_filter( 'stm_lms_co_instructor_avatar','stm_lms_co_instructor_avatar_function', 10, 1);

function stm_lms_co_instructor_avatar_function($author_avatar){
	$user_id = get_current_user_id();
	$avatar_size = 215;
	if($user_id == 1){
		$author_avatar = get_avatar( $user_id, $avatar_size );	
	}	
	return $author_avatar;
}
```

***

9. `stm_lms_co_instructor_login`

**Description:**\
Returns the instructor’s full name.

**Parameters:**

* `$author_login` (string)

```php
add_filter( 'stm_lms_co_instructor_login', 'stm_lms_co_instructor_login_function', 10, 1);

function stm_lms_co_instructor_login_function($author_login){
	$user_id = get_current_user_id();
	if($user_id == 22){
		return 'John Doe';
	}

	return $author_login;
}
```

***

## Addons Settings

**Available filters:**

* `stm_lms_course_bundle_settings`
* `stm_lms_google_classrooms_settings`
* `stm_lms_multi_instructor_settings`
* `stm_lms_scorm_settings`
* `stm_lms_shareware_settings`
* `stm_lms_email_manager_settings`
* `stm_lms_enterprise_courses_settings`
* `stm_lms_media_library_settings`
* `stm_lms_point_system_settings`
* `stm_lms_sequential_drip_content_settings`
* `stm_lms_udemy_settings`

**Hooks for configuring addons. Example:**

```php
add_filter('stm_lms_course_bundle_settings', 'stm_lms_course_bundle_settings_function', 10, 1);
function stm_lms_course_bundle_settings_function($settings){
	unset( $settings['field_key'] ); // Remove Settings

      // Add new Settings
	$settings['credentials'] = array(
		'name'   => esc_html__( 'Custom settings', 'masterstudy-lms-learning-management-system-pro' ),
		'fields' => array(
			'custom_quantity' => array(
				'type'  => 'text',
				'label' => esc_html__( 'Demo settings text', 'masterstudy-lms-learning-management-system-pro' ),
			),
			'custom_limit'    => array(
				'type'  => 'text',
				'label' => esc_html__( 'Demo limit', 'masterstudy-lms-learning-management-system-pro' ),
				'hint'  => esc_html__( 'Custom information to apply', 'masterstudy-lms-learning-management-system-pro' ),
			),
		),
	);
	
	return $settings;
}
```

### Course Completion Messages

**Available filters:**

* `masterstudy_lms_course_completed_message`
* `masterstudy_lms_course_not_completed_message`

**Examples:**

```php
add_filter('masterstudy_lms_course_completed_message', 'stm_lms_course_completed_message', 10, 1);
function stm_lms_course_bundle_settings_function($message, $course_id, $course_passsed){
	return esc_html__('You have successfully completed the course!');
}
```

```php
add_filter('masterstudy_lms_course_not_completed_message', 'stm_lms_course_completed_message', 10, 1);
function stm_lms_course_bundle_settings_function($message, $course_id, $course_passsed){
	return esc_html__('You have NOT completed the course!');
}
```


---

# Agent Instructions: Querying This Documentation

If you need additional information that is not directly available in this page, you can query the documentation dynamically by asking a question.

Perform an HTTP GET request on the current page URL with the `ask` query parameter:

```
GET https://docs.stylemixthemes.com/masterstudy-lms/developers-guide/masterstudy-lms-hooks/additional-pro-hooks.md?ask=<question>
```

The question should be specific, self-contained, and written in natural language.
The response will contain a direct answer to the question and relevant excerpts and sources from the documentation.

Use this mechanism when the answer is not explicitly present in the current page, you need clarification or additional context, or you want to retrieve related documentation sections.
