> For the complete documentation index, see [llms.txt](https://docs.stylemixthemes.com/llms.txt). Markdown versions of documentation pages are available by appending `.md` to page URLs; this page is available as [Markdown](https://docs.stylemixthemes.com/masterstudy-lms/developers-guide/masterstudy-lms-hooks/point-system.md).

# Point System

## Actions

**Dynamic Hook:** `do_action( "stm_lms_score_charge_{$action_id}", $user_id, $action_id, $action['score'], time() )`

This dynamic action hook is triggered whenever a point-related action occurs. Depending on the action type (`$action_id`), the user can be awarded points.

**Available `$action_id` values:**

* `user_registered`
* `course_purchased`
* `assignment_passed`
* `certificate_received`
* `quiz_passed`
* `perfect_quiz`
* `lesson_passed`
* `group_joined`
* `friends_friendship_accepted`
* `course_bought`

**Parameters:**

* `$user_id` (integer) — The ID of the user receiving points.
* `$action_id` (string) — The action identifier.&#x20;
* `$time` (integer) — The timestamp when the action occurred.

**Example: `stm_lms_score_charge_course_purchased`**

**Description:** \
Triggered when a course is purchased. Allows developers to modify or add to the points awarded for this specific action.

**Example usage:**

```php
add_action( 'stm_lms_score_charge_course_purchased', 'stm_lms_score_charge_course_purchased_function', 10, 4 );

function stm_lms_score_charge_course_purchased( $user_id, $action_id, $score, $time ) {
	global $wpdb;
	$table_name = $wpdb->prefix . 'stm_lms_user_points';

	// Adding custom points
	$score      += 10;
	$user_points = array(
		'user_id'   => $user_id,
		'action_id' => $action_id,
		'score'     => $score,
		'timestamp' => $time,
		'completed' => false,
	);

	$wpdb->insert(
		$table_name,
		$user_points
	);

}
```

## Filters

1. `stm_lms_display_points`

**Description:**\
Filters the way user points are displayed. You can modify the default points output and return a custom format.

**Parameters:**

* `$points` (string) — The current points string.

**Example usage:**

```php
add_filter( 'stm_lms_display_points', 'stm_lms_display_points_function', 10, 1 );

function stm_lms_display_points_function( $points ) {
	$user_id = get_current_user_id();

	if ( $user_id == 1 ) {
		$points = '4.5 Gpa';
	}
	return $points;
}
```

**Explanation:**\
This example overrides the points display for a specific user (ID = 1) and shows **4.5 GPA** instead of the regular score.


---

# Agent Instructions
This documentation is published with GitBook. GitBook is the documentation platform designed so that both humans and AI agents can read, navigate, and reason over technical content effectively. Learn more at gitbook.com.

## 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, and the optional `goal` query parameter:

```
GET https://docs.stylemixthemes.com/masterstudy-lms/developers-guide/masterstudy-lms-hooks/point-system.md?ask=<question>&goal=<endgoal>
```

`ask` is the immediate question: it should be specific, self-contained, and written in natural language.
`goal` is optional and describes the broader end goal you are ultimately trying to accomplish on behalf of the user. GitBook uses it to tailor the answer towards what is most useful for that goal.

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.
