kanbanpress_log_event hook

Hook Overview

The kanbanpress_log_event hook is triggered whenever an event is logged by the KanbanPress History Log plugin. It allows developers to hook into this action and add custom log entries.

Hook Parameters

  • $post_id (int): The ID of the post where the event occurred.
  • $log_details (string): A description of the event.
  • $board_index (int): The index of the Kanban board.
  • $history_entry (string): The HTML-formatted history entry.

Usage Example

To log a custom event using the kanbanpress_log_event hook, you can add the following code to your plugin or theme:

phpCopy code// Hook into KanbanPress History Log to add custom log entries
function my_custom_log_event($post_id, $log_details, $board_index, $history_entry) {
    // Define the custom log details
    $custom_log_details = "Custom event by user@example.com: {$log_details}";

    // Create the custom history entry
    $custom_history_entry = "<div class='history-entry'><span class='history-symbol'>⭐</span><span class='history-tooltip'>" . current_time('m-d-y H:i:s') . "</span> {$custom_log_details}</div>";

    // Add the custom history entry to the post
    add_post_meta($post_id, 'column_history', $custom_history_entry);
}

// Add the action to log custom events
add_action('kanbanpress_log_event', 'my_custom_log_event', 10, 4);

Steps to Integrate

  1. Add the Action Hook: Place the add_action code in your plugin or theme’s functions file to hook into kanbanpress_log_event.
  2. Define the Callback Function: Implement the my_custom_log_event function to create and add your custom log entries.
  3. Create Custom Log Details: Customize the $custom_log_details and $custom_history_entry to fit your requirements.
  4. Update Post Meta: Use add_post_meta to store each log entry individually.

Notes

  • Ensure that your callback function is efficient to prevent performance issues.
  • You can use the $board_index parameter to log board-specific details.
  • This approach helps maintain clean and organized log entries for each post.

By using the kanbanpress_log_event hook, you can extend the functionality of the KanbanPress History Log plugin to include custom events, providing a robust history logging system for your Kanban boards.