Add action hooks to Follow/Reminder toggles

This commit is contained in:
Tetrakern 2024-05-30 15:56:56 +02:00
parent a402bd03c3
commit 09be144a0f
3 changed files with 20 additions and 0 deletions

View File

@ -1107,6 +1107,24 @@ Fires right between the comments list and heading in the `fictioneer_story_comme
---
### `do_action( 'fictioneer_toggled_follow', $story_id, $force )`
Fires after a Follow has been successfully toggled and right before the JSON response is sent.
**$args:**
* $story_id (int) ID of the story.
* $force (bool) Whether the Follow was toggled on (true) or off (false).
---
### `do_action( 'fictioneer_toggled_reminder', $story_id, $force )`
Fires after a Reminder has been successfully toggled and right before the JSON response is sent.
**$args:**
* $story_id (int) ID of the story.
* $force (bool) Whether the Reminder was toggled on (true) or off (false).
---
### `do_action( 'fictioneer_top_header', $args )`
Fires right after opening the top-aligned `<header>` container.

View File

@ -104,6 +104,7 @@ function fictioneer_ajax_toggle_follow() {
delete_user_meta( $user->ID, 'fictioneer_user_follows_cache' );
if ( update_user_meta( $user->ID, 'fictioneer_user_follows', $user_follows ) ) {
do_action( 'fictioneer_toggled_follow', $story_id, $set );
wp_send_json_success();
} else {
wp_send_json_error( array( 'error' => __( 'Database error. Follows could not be updated.', 'fictioneer' ) ) );

View File

@ -97,6 +97,7 @@ function fictioneer_ajax_toggle_reminder() {
// Update database & response
if ( update_user_meta( $user->ID, 'fictioneer_user_reminders', $user_reminders ) ) {
do_action( 'fictioneer_toggled_reminder', $story_id, $set );
wp_send_json_success();
} {
wp_send_json_error( array( 'error' => __( 'Database error. Reminders could not be updated.', 'fictioneer' ) ) );