### Using wpdiscuz_before_getcomments Hook Source: https://wpdiscuz.com/docs/codex/actions/wpdiscuz_before_getcomments This example demonstrates how to hook into wpdiscuz_before_getcomments to perform custom actions, such as initializing custom actions if a user is logged in. It receives the merged comment arguments, the current user object, and the function arguments. ```php add_action("wpdiscuz_before_getcomments", function ($commentsArgs, $currentUser, $args) { if (!empty($currentUser->ID)) { $customValues = $this->init_custom_actions(); } }, 10, 3); ``` -------------------------------- ### is_load_wpdiscuz Source: https://wpdiscuz.com/docs/codex/filters/is_load_wpdiscuz This filter can be used to check whether wpDiscuz should load. It is available starting from version 7.0.0. ```APIDOC ## is_load_wpdiscuz Filter ### Description This filter allows you to determine whether the wpDiscuz comment system should be loaded on the current page. By default, it controls the loading based on certain conditions, but you can modify this behavior. ### Parameters - **$load** (bool) - Determines whether wpDiscuz should be added to the current page. This is the initial state determined by wpDiscuz. - **$post** (WP_Post object) - The object of the current post being displayed. ### Usage Example ```php add_filter("is_load_wpdiscuz", function ($load, $post) { // Load wpDiscuz if it's already set to load, or if it's an archive page. return $load || is_archive(); }, 10, 2); ``` ### Changelog Added starting from version 7.0.0. ``` -------------------------------- ### Add wpDiscuz to Admin Pages Source: https://wpdiscuz.com/docs/codex/filters/wpdiscuz_wp_admin_pages Use this filter to add custom admin page slugs to the array of pages where wpDiscuz should be loaded. This example adds the 'profile.php' page. ```php add_filter("wpdiscuz_wp_admin_pages", function ($pages) { $pages[] = "profile.php"; return $pages; }); ``` -------------------------------- ### Using wpdiscuz_add_rating Hook Source: https://wpdiscuz.com/docs/codex/actions/wpdiscuz_add_rating This example demonstrates how to hook into the 'wpdiscuz_add_rating' action to perform a custom function when a post is rated. It checks if a custom function exists before calling it. ```php add_action("wpdiscuz_add_rating", function ($rating, $postId) { if (function_exists("my_custom_function")) { my_custom_function($rating, $postId); } }, 10, 2); ``` -------------------------------- ### Modify Comment Arguments with wpdiscuz_comments_args Source: https://wpdiscuz.com/docs/codex/filters/wpdiscuz_comments_args Use this filter to change the default orderby and order of comments. This example sets comments to be ordered by date in ascending order. ```php add_filter("wpdiscuz_comments_args", function ($args) { $args["orderby"] = "comment_date"; $args["order"] = "asc"; return $args; }); ``` -------------------------------- ### wpdiscuz_init_options Source: https://wpdiscuz.com/docs/codex/actions/wpdiscuz_option_page This action is triggered during the initialization of wpDiscuz options. ```APIDOC ## Action: wpdiscuz_init_options ### Description This action hook runs during the initialization phase where wpDiscuz options are loaded or prepared. It's useful for modifying default options or adding custom ones. ### Usage ```php do_action( 'wpdiscuz_init_options' ); ``` ``` -------------------------------- ### Comment Text Breaking Logic Example Source: https://wpdiscuz.com/docs/wpdiscuz-7/plugin-settings/comment-content-and-media Illustrates how wpDiscuz breaks long comment texts and the potential impact on HTML formatting when the 'Read More' functionality is used. This example shows the issue of missing closing HTML tags. ```html Lorem ipsum dolor sit amet. **

**Falli interesset vel, no has erant fastidii concludaturque, ea cetero.**

** ``` ```html Lorem ipsum dolor sit amet. **

**Falli interesset vel, no has erant fastidii **Read More>>** ``` -------------------------------- ### wpdiscuz_user_label Source: https://wpdiscuz.com/docs/codex/actions/wpdiscuz_editor_modules Gets the display label for a user role. ```APIDOC ## wpdiscuz_user_label ### Description This function returns a user-friendly label associated with a specific user role, used for display purposes within the comment section. ### Method Function ### Endpoint N/A (Server-side function) ### Parameters - **role** (string) - Required - The user role for which to get the label. ### Request Example N/A ### Response String: The display label for the given user role. ``` -------------------------------- ### wpdiscuz_init_options Source: https://wpdiscuz.com/docs/codex/actions/wpdiscuz_init_options The wpdiscuz_init_options action is a core part of the wpDiscuz 7 API, responsible for initializing various options and settings. It is part of a larger set of actions and functions available for customizing comment functionality. ```APIDOC ## wpdiscuz_init_options ### Description Initializes the options for wpDiscuz. ### Method Action Hook ### Endpoint N/A (PHP Action Hook) ### Parameters This action hook does not accept direct parameters but operates within the WordPress environment to initialize options. ### Request Example ```php do_action( 'wpdiscuz_init_options' ); ``` ### Response This action hook modifies global settings and options within the WordPress environment. No direct response is returned. ``` -------------------------------- ### wpdiscuz_before_load Source: https://wpdiscuz.com/docs/codex/actions/wpdiscuz_before_load This action hook fires before the main wpDiscuz functionality is loaded. It can be used to hook into the plugin's initialization process. ```APIDOC ## wpdiscuz_before_load ### Description This action hook is triggered before the core functionality of wpDiscuz is loaded. It provides a point for developers to add custom actions or filters that need to be executed early in the plugin's lifecycle. ### Usage ```php do_action( 'wpdiscuz_before_load' ); ``` ### Parameters This hook does not accept any parameters. ``` -------------------------------- ### wpdiscuz_enable_human_readable_numbers Source: https://wpdiscuz.com/docs/codex/filters/wpdiscuz_enable_human_readable_numbers This filter allows you to modify the output of numbers to be more human-readable. For example, you can change '1000' to '1k'. ```APIDOC ## wpdiscuz_enable_human_readable_numbers ### Description Filters the number to make it human-readable. This is useful for displaying large numbers in a more concise format, such as converting 1000 to 1k. ### Parameters * **$number** (int|float) - The number to be filtered. * **$post_id** (int) - The ID of the post where the number is displayed. ### Return * (string) - The human-readable formatted number. ``` -------------------------------- ### wpdiscuz_init_options Source: https://wpdiscuz.com/docs/codex/actions/wpdiscuz_init_options This action hook is triggered during the initialization of wpDiscuz options. It can be used to modify or extend the default options before they are loaded. ```APIDOC ## wpdiscuz_init_options ### Description This action hook is triggered during the initialization of wpDiscuz options. It can be used to modify or extend the default options before they are loaded. ### Method Action Hook ### Endpoint N/A (PHP Hook) ### Parameters This hook does not accept any parameters directly, but it runs within the context of wpDiscuz option initialization. ### Request Example ```php add_action( 'wpdiscuz_init_options', 'my_custom_wpdiscuz_options' ); function my_custom_wpdiscuz_options() { // Custom option modifications here // For example, you might want to add a new option or change a default value. // Note: Direct modification of global options might require specific knowledge of wpDiscuz's internal structure. } ``` ### Response N/A (Modifies internal options) ``` -------------------------------- ### wpdiscuz_settings Source: https://wpdiscuz.com/docs/codex/actions/wpdiscuz_editor_modules Provides access to wpDiscuz settings. ```APIDOC ## wpdiscuz_settings ### Description This function or action likely retrieves or manages the settings for the wpDiscuz plugin. ### Method Function/Action Hook ### Endpoint N/A (Server-side function/hook) ### Parameters None explicitly documented. ### Request Example N/A ### Response Likely returns an array or object containing wpDiscuz settings. ``` -------------------------------- ### wpdiscuz_is_comment_editable Source: https://wpdiscuz.com/docs/codex/filters/wpdiscuz_is_comment_editable This filter hook allows you to disable the comment editing functionality. It is available starting from version 7.0.8. ```APIDOC ## wpdiscuz_is_comment_editable ### Description This hook allows you to disable the comment editing. ### Parameters - **$isEditable** (bool) - Determines if the comment should be editable. - **$comment** (WP_Comment object) - The current comment object. ### Usage ```php add_filter("wpdiscuz_is_comment_editable", function ($isEditable, $comment) { // Return false to disable editing return false; }, 10, 2); ``` ### Changelog Added in version 7.0.8 ``` -------------------------------- ### wpdiscuz_comments_order_by Source: https://wpdiscuz.com/docs/codex/filters/wpdiscuz_comments_order_by This filter hook allows you to change the default field used for sorting comments. It is available starting from version 7.0.3. ```APIDOC ## wpdiscuz_comments_order_by Filter ### Description This hook is used to filter which field will be made for the sorting. ### Parameters #### Parameters - **$orderBy** (string) - The default field for the sorting. ### Usage ```php add_filter("wpdiscuz_comments_order_by", function ($orderBy) { return "comment_date"; }); ``` ### Notes - Search field cannot be blank. ``` -------------------------------- ### wpdiscuz_form_init Action Source: https://wpdiscuz.com/docs/codex/actions/wpdiscuz_form_init This action is triggered during the initialization of the wpDiscuz form. It can be used to perform actions or modify form elements before the form is rendered. ```APIDOC ## wpdiscuz_form_init ### Description This action hook is fired when the wpDiscuz form is initialized. It allows developers to add custom functionality or modify the form's behavior at this stage. ### Method Action Hook ### Endpoint N/A (PHP Hook) ### Parameters This hook does not accept any direct parameters, but functions hooked into it can access global WordPress and wpDiscuz variables. ### Request Example ```php add_action( 'wpdiscuz_form_init', 'my_custom_form_init_function' ); function my_custom_form_init_function() { // Custom code to run when the form is initialized // For example, you could add custom fields or modify form settings } ``` ### Response N/A (This is an action hook, not a function that returns a value directly to the caller in this context.) #### Success Response (N/A) N/A #### Response Example N/A ``` -------------------------------- ### wpdiscuz_add_vote Source: https://wpdiscuz.com/docs/codex/actions/wpdiscuz_add_vote This hook allows you to perform an action when a user votes on a comment for the first time. It was added starting from version 7.0.0. ```APIDOC ## wpdiscuz_add_vote ### Description This hook allows you to perform an action when a user votes on a comment for the first time. ### Parameters #### Hook Parameters - **$voteType** (int) - The type of the vote (like or dislike). - **$comment** (WP_Comment object) - The object of the comment. ### Usage Example ```php add_action("wpdiscuz_add_vote", function ($voteType, $comment) { if ($comment->user_id) { update_user_meta($comment->user_id, "user_votes", intval(get_user_meta($comment->user_id, "user_votes", true)) + $voteType); } }, 10, 2); ``` ``` -------------------------------- ### Insert Custom Message After Form Head Source: https://wpdiscuz.com/docs/codex/actions/comment_main_form_after_head Use this action to echo custom HTML content. This example inserts a simple text message. ```php add_action("comment_main_form_after_head", function () { echo "Custom Message"; }); ``` -------------------------------- ### wpdiscuz_settings_tab_after Source: https://wpdiscuz.com/docs/codex/actions/wpdiscuz_option_page This action is triggered after a settings tab is displayed. ```APIDOC ## Action: wpdiscuz_settings_tab_after ### Description This action hook is fired after a specific settings tab has been rendered in the wpDiscuz admin area. It allows for adding content or functionality after the main tab content. ### Usage ```php do_action( 'wpdiscuz_settings_tab_after', $current_tab ); ``` ### Parameters * **$current_tab** (string) - The slug of the currently displayed settings tab. ``` -------------------------------- ### Modify Author Link Attributes Source: https://wpdiscuz.com/docs/codex/filters/wpdiscuz_author_link_attributes Use this filter to change the attributes of the link printed on the comment author name. This example removes the target attribute. ```php add_filter("wpdiscuz_author_link_attributes", function ($attrs) { $attrs["target"] = ""; return $attrs; }); ``` -------------------------------- ### wpdiscuz_source_to_image_conversion Source: https://wpdiscuz.com/docs/codex/actions/wpdiscuz_editor_modules Handles the conversion of source content to an image format. ```APIDOC ## wpdiscuz_source_to_image_conversion ### Description This function or action is likely used for converting certain content elements, possibly related to comments or user avatars, into an image format. ### Method Function/Action Hook ### Endpoint N/A (Server-side function/hook) ### Parameters None explicitly documented. ### Request Example N/A ### Response Likely returns image data or a path to the generated image. ``` -------------------------------- ### wpdiscuz_walker_include Source: https://wpdiscuz.com/docs/codex/filters/wpdiscuz_dashboard_tools Filter to include custom walker files. ```APIDOC ## wpdiscuz_walker_include ### Description Allows inclusion of custom walker files for comment display or processing. ### Method Filter ### Parameters None explicitly documented. ### Response Mixed - Path or data related to walker files. ``` -------------------------------- ### wpdiscuz_privacy_personal_data_export Source: https://wpdiscuz.com/docs/codex/filters/wpdiscuz_privacy_personal_data_export This filter allows you to hook into the process of exporting personal data for users within wpDiscuz. You can use it to add or modify the data that gets exported. ```APIDOC ## wpdiscuz_privacy_personal_data_export ### Description Filters the personal data that will be exported for a user. ### Usage ```php add_filter( 'wpdiscuz_privacy_personal_data_export', 'your_function_name' ); ``` ### Parameters This filter does not accept any parameters directly. It is intended to be used with the `WP_Privacy_Data_Exporter` class, which provides the context and data to be filtered. ``` -------------------------------- ### Add Custom Sorting Button Source: https://wpdiscuz.com/docs/codex/filters/wpdiscuz_sorting_buttons_array Use this filter to add a new sorting button to the comment sorting options. This example adds a 'Custom' sort option. ```php add_filter("wpdiscuz_sorting_buttons_array", function ($buttons) { $buttons[] = [ "orderBy" => "comment_date", "order" => "desc", "class" => "wpdiscuz-custom-sort", "text" => "Custom", "type" => "custom", ]; return $buttons; }); ``` -------------------------------- ### wpdiscuz_before_submit_button_in_wrapper Source: https://wpdiscuz.com/docs/codex/actions/wpdiscuz_option_page This action is executed before the submit button within its wrapper. ```APIDOC ## Action: wpdiscuz_before_submit_button_in_wrapper ### Description This action hook runs before the submit button is displayed within its designated wrapper element in the comment form. ### Usage ```php do_action( 'wpdiscuz_before_submit_button_in_wrapper' ); ``` ``` -------------------------------- ### wpdiscuz_form_init Source: https://wpdiscuz.com/docs/codex/actions/wpdiscuz_form_init The wpdiscuz_form_init action is a hook provided by wpDiscuz 7 that allows developers to interact with or modify the form initialization process. It can be used to add custom fields, modify default settings, or perform other actions before the comment form is rendered. ```APIDOC ## wpdiscuz_form_init ### Description This action hook is triggered during the initialization of the wpDiscuz comment form. It provides an opportunity to hook into the form's setup process. ### Usage ```php add_action( 'wpdiscuz_form_init', 'your_custom_function' ); function your_custom_function() { // Your custom code here } ``` ### Parameters This action does not accept any parameters directly. However, it operates within the context of the wpDiscuz form initialization, and global variables or other hooks might be available. ``` -------------------------------- ### Change Comment Sorting Order Source: https://wpdiscuz.com/docs/codex/filters/wpdiscuz_comments_order Use this filter to change the default comment sorting order. For example, to sort comments in ascending order, return 'asc'. ```php add_filter("wpdiscuz_comments_order", function ($order) { return "asc"; }); ``` -------------------------------- ### wpdiscuz_before_load Source: https://wpdiscuz.com/docs/codex/actions/wpdiscuz_before_load This action hook is triggered before the wpDiscuz script and styles are loaded. It can be used to enqueue additional scripts or styles, or to modify wpDiscuz's behavior before it initializes. ```APIDOC ## wpdiscuz_before_load ### Description This action hook is executed before the wpDiscuz plugin loads its main scripts and styles. It provides an opportunity to add custom functionality or modify existing behavior prior to wpDiscuz's initialization. ### Usage ```php do_action( 'wpdiscuz_before_load' ); ``` ``` -------------------------------- ### Update Post Meta After Subscriber Notification Source: https://wpdiscuz.com/docs/codex/actions/wpdiscuz_notify_post_subscribers Use this hook to update post meta after a subscriber has been notified. This example marks that subscribers have been notified for a specific comment. ```php add_action("wpdiscuz_notify_post_subscribers", function ($postId, $commentId, $subscriberUserId, $subscriberEmail) { update_post_meta($postId, "post_subscribers_notified_for_" . $commentId, 1); }, 10, 4); ``` -------------------------------- ### wpdiscuz_settings Source: https://wpdiscuz.com/docs/codex/filters/wpdiscuz_ajax_callbacks Retrieves or updates wpDiscuz settings via AJAX. ```APIDOC ## wpdiscuz_settings ### Description Manages wpDiscuz plugin settings through AJAX requests. This can include fetching current settings or applying updates. ### Method AJAX Callback ### Parameters None explicitly documented for direct invocation. ### Response None explicitly documented for direct invocation. ``` -------------------------------- ### Execute Custom Actions Before wpDiscuz Loads Source: https://wpdiscuz.com/docs/codex/actions/wpdiscuz_before_load Use this hook to perform custom actions, such as initializing custom functionalities, before wpDiscuz loads. It checks if a user is logged in before proceeding with custom actions. ```php add_action("wpdiscuz_before_load", function ($post, $currentUser, $empty) { if (!empty($currentUser->ID)) { $this->init_custom_actions($post); } }, 10, 3); ``` -------------------------------- ### wpdiscuz_before_load Action Hook Source: https://wpdiscuz.com/docs/codex/actions/wpdiscuz_before_load This hook can be used for doing some action before the wpDiscuz is being loaded. It is available since version 7.0.0. ```APIDOC ## wpdiscuz_before_load Hook ### Description This action hook allows you to perform custom actions or modify behavior before the wpDiscuz comment system is loaded on a post. ### Parameters - **$post** (WP_Post object) - The current post object. - **$currentUser** (WP_User object) - The user object that is currently logged in. ### Usage Example ```php add_action("wpdiscuz_before_load", function ($post, $currentUser, $empty) { if (!empty($currentUser->ID)) { // Example: Initialize custom actions if the user is logged in $this->init_custom_actions($post); } }, 10, 3); ``` ### Changelog - since 7.0.0 version ``` -------------------------------- ### Change Inline Commenter Email Source: https://wpdiscuz.com/docs/codex/filters/wpdiscuz_feedback_commenter_email Use this filter to dynamically change the email address of the inline comment author. This example generates a unique email address for each comment. ```php add_filter("wpdiscuz_feedback_commenter_email", function ($email) { return uniqid() . "@example.com"; }); ``` -------------------------------- ### Accessing wpDiscuz Options After Initialization Source: https://wpdiscuz.com/docs/codex/actions/wpdiscuz_init_options Use this hook to access and read wpDiscuz options after they have been initialized. The hook provides the WpdiscuzOptions object, allowing you to retrieve settings like native AJAX enablement. ```php add_action("wpdiscuz_init_options", function ($options) { $isNativeAjaxEnabled = $options->general["isNativeAjaxEnabled"]; }); ``` -------------------------------- ### wpdiscuz_content_modal_title Source: https://wpdiscuz.com/docs/codex/filters/wpdiscuz_content_modal_title Filters the title of the content modal. This filter allows developers to dynamically change the title displayed in the content modal, for example, to include user-specific information or context. ```APIDOC ## wpdiscuz_content_modal_title ### Description Filters the title of the content modal. ### Parameters This filter does not accept any parameters directly but operates on the title string. ### Example ```php add_filter( 'wpdiscuz_content_modal_title', 'my_custom_modal_title' ); function my_custom_modal_title( $title ) { // Modify the title here return 'My Custom Modal Title'; } ``` ``` -------------------------------- ### wpdiscuz_init_options Filter Source: https://wpdiscuz.com/docs/codex/filters/wpdiscuz_wp_admin_pages This filter allows modification of the default options used during wpDiscuz initialization. ```APIDOC ## wpdiscuz_init_options Filter ### Description Filters the default options array used for initializing wpDiscuz. ### Parameters - **$options** (array) - The default options array. ### Returns - (array) - The modified options array. ``` -------------------------------- ### wpdiscuz_front_scripts Source: https://wpdiscuz.com/docs/codex/actions/wpdiscuz_front_scripts This action hook is used to enqueue or manage front-end scripts for wpDiscuz. ```APIDOC ## wpdiscuz_front_scripts ### Description This action hook is designed to be used for enqueuing or managing front-end JavaScript and CSS files required by wpDiscuz on the website's front-end. ### Usage Plugins or themes can hook into this action to add their own scripts or modify wpDiscuz's script dependencies. ### Example ```php add_action( 'wpdiscuz_front_scripts', 'my_custom_scripts' ); function my_custom_scripts() { // Enqueue a custom script wp_enqueue_script( 'my-wpdiscuz-script', get_template_directory_uri() . '/js/my-wpdiscuz-script.js', array( 'jquery' ), '1.0', true ); // Enqueue a custom stylesheet wp_enqueue_style( 'my-wpdiscuz-style', get_template_directory_uri() . '/css/my-wpdiscuz-style.css', array(), '1.0' ); } ``` ``` -------------------------------- ### Change Commenter Email Source: https://wpdiscuz.com/docs/codex/filters/wpdiscuz_commenter_email Use this filter to dynamically generate a new email address for the commenter. This example generates a unique email address using uniqid() and a domain. ```php add_filter("wpdiscuz_commenter_email", function ($email) { return uniqid() . "@example.com"; }); ``` -------------------------------- ### wpdiscuz_check_version Source: https://wpdiscuz.com/docs/codex/actions/wpdiscuz_check_version This action is used to check the version of wpDiscuz. ```APIDOC ## wpdiscuz_check_version ### Description Checks the current version of the wpDiscuz plugin. ### Method Not applicable (this is a PHP function/action hook). ### Endpoint Not applicable. ### Parameters None explicitly documented. ### Request Example Not applicable. ### Response Not applicable (typically returns version information or performs an action). ``` -------------------------------- ### Allow Specific User Roles to Comment Source: https://wpdiscuz.com/docs/codex/filters/wpdiscuz_user_role_can_comment Use this filter to conditionally allow or disallow commenting for certain user roles. The example demonstrates enabling comments for 'editor' role. ```php add_filter("wpdiscuz_user_role_can_comment", function ($canComment, $role) { if ($role === "editor") { $canComment = true; } return $canComment; }, 10, 2); ``` -------------------------------- ### wpdiscuz_user_settings_button Source: https://wpdiscuz.com/docs/codex/actions/wpdiscuz_editor_modules Generates or manages the user settings button. ```APIDOC ## wpdiscuz_user_settings_button ### Description This function is responsible for outputting or handling the user settings button, which allows users to manage their preferences. ### Method Function ### Endpoint N/A (Server-side function) ### Parameters None explicitly documented. ### Request Example N/A ### Response HTML or string representing the user settings button. ``` -------------------------------- ### Modify wpDiscuz Phrases with wpdiscuz_phrase Source: https://wpdiscuz.com/docs/codex/filters/wpdiscuz_phrase Use this filter to change specific phrases displayed by wpDiscuz. For example, this snippet replaces 'comment' with 'reply' in the phrase associated with the 'wc_user_settings_subscribed_to_replies' key. ```php add_filter("wpdiscuz_phrase", function ($phrase, $key, $args) { if ($key === "wc_user_settings_subscribed_to_replies") { $phrase = str_replace("comment", "reply", $phrase); } return $phrase; }, 10, 3); ``` -------------------------------- ### wpDiscuz Button Actions Source: https://wpdiscuz.com/docs/codex/actions/wpdiscuz_button_actions A list of available actions and functions that can be hooked into or called to manage button behaviors and user interactions in wpDiscuz. ```APIDOC ## wpDiscuz Button Actions This section details various actions and functions available within the wpDiscuz plugin that relate to button functionalities and user interactions. These can be used for customization and extending plugin behavior. ### Available Actions and Functions: - `wpdiscuz_send_email_on_approving`: Action hook for sending emails when a comment is approved. - `wpdiscuz_settings`: Function to retrieve or manage wpDiscuz settings. - `wpdiscuz_show_comments_left`: Function to display the number of comments left. - `wpdiscuz_show_field_for_user`: Function to determine if a field should be shown for a user. - `wpdiscuz_social_login_response`: Action hook for handling social login responses. - `wpdiscuz_sorting_buttons_array`: Filter hook to modify the array of sorting buttons. - `wpdiscuz_source_to_image_conversion`: Function related to image conversion. - `wpdiscuz_thread_end`: Action hook for the end of a comment thread. - `wpdiscuz_uploads_folder`: Function to get the uploads folder path. - `wpdiscuz_user_can_view_field`: Function to check if a user can view a specific field. - `wpdiscuz_user_can_view_fields`: Function to check if a user can view multiple fields. - `wpdiscuz_user_info_and_logout_link`: Function to get user information and logout link. - `wpdiscuz_user_label`: Function to get the user label. - `wpdiscuz_user_role_can_comment`: Function to check if a user role can comment. - `wpdiscuz_user_role_can_see_comments`: Function to check if a user role can see comments. - `wpdiscuz_user_settings_button`: Function to display the user settings button. - `wpdiscuz_username_classes`: Filter hook to add classes to the username. - `wpdiscuz_validate_nonce_for_guests`: Function to validate nonces for guests. - `wpdiscuz_walker_include`: Function to include a walker for comment display. - `wpdiscuz_wp_admin_pages`: Action hook for wpDiscuz admin pages. ``` -------------------------------- ### Update Comment Meta After Follower Notification Source: https://wpdiscuz.com/docs/codex/actions/wpdiscuz_notify_followers Use this hook to perform actions after follower email notifications are sent. This example updates comment meta to mark followers as notified. ```php add_action("wpdiscuz_notify_followers", function ($comment, $followerData) { update_comment_meta($comment->comment_ID, "followers_notified", 1); }, 10, 2); ``` -------------------------------- ### Add Custom Module to Comment Editor Source: https://wpdiscuz.com/docs/codex/actions/wpdiscuz_editor_modules Use this action hook to add custom modules or options to the comment form editor. This example adds a 'customModule' with a 'customOption' and 'customValue'. ```php add_action("wpdiscuz_editor_modules", function () { echo "customModule: {customOption: customValue},"; }); ``` -------------------------------- ### wpdiscuz_validate_nonce_for_guests Source: https://wpdiscuz.com/docs/codex/actions/wpdiscuz_editor_modules Validates a nonce for guest users. ```APIDOC ## wpdiscuz_validate_nonce_for_guests ### Description This function checks the validity of a security nonce specifically for users who are not logged in (guests). ### Method Function ### Endpoint N/A (Server-side function) ### Parameters - **nonce** (string) - Required - The nonce string to validate. - **action** (string) - Optional - The action associated with the nonce. ### Request Example N/A ### Response Boolean: true if the nonce is valid for a guest, false otherwise. ``` -------------------------------- ### Using wpdiscuz_after_comment_post Hook Source: https://wpdiscuz.com/docs/codex/actions/wpdiscuz_after_comment_post This example demonstrates how to hook into the 'wpdiscuz_after_comment_post' action to retrieve the ID of the newly posted comment. The hook passes the comment object and the current user object. ```php add_action("wpdiscuz_after_comment_post", function ($newComment, $currentUser) { $newCommentId = $newComment->comment_ID; }, 10, 2); ``` -------------------------------- ### wpdiscuz_user_info_and_logout_link Source: https://wpdiscuz.com/docs/codex/actions/wpdiscuz_editor_modules Retrieves user information and the logout link for logged-in users. ```APIDOC ## wpdiscuz_user_info_and_logout_link ### Description This function likely fetches details about the currently logged-in user and generates the appropriate logout URL. ### Method Function ### Endpoint N/A (Server-side function) ### Parameters None explicitly documented. ### Request Example N/A ### Response An array or object containing user information and the logout link. ``` -------------------------------- ### wpdiscuz_submit_button_before Source: https://wpdiscuz.com/docs/codex/actions/wpdiscuz_option_page This action is executed before the submit button is rendered. ```APIDOC ## Action: wpdiscuz_submit_button_before ### Description This action hook runs immediately before the submit button of the comment form is displayed. It can be used to insert elements or modify the form layout before the button. ### Usage ```php do_action( 'wpdiscuz_submit_button_before' ); ``` ``` -------------------------------- ### Display Custom Message After Subscription Form Source: https://wpdiscuz.com/docs/codex/actions/wpdiscuz_after_subscription_form Use this action hook to echo custom HTML or messages after the subscription form. This is a basic example demonstrating how to add static content. ```php add_action("wpdiscuz_after_subscription_form", function () { echo "Custom Message"; }); ``` -------------------------------- ### wpdiscuz_button_actions Source: https://wpdiscuz.com/docs/codex/actions/wpdiscuz_option_page This action is executed within the context of button actions. ```APIDOC ## Action: wpdiscuz_button_actions ### Description This action hook is designed to allow developers to add custom actions or modify existing ones related to buttons within the wpDiscuz interface. ### Usage ```php do_action( 'wpdiscuz_button_actions' ); ``` ``` -------------------------------- ### Change Verification Key Expiration Time Source: https://wpdiscuz.com/docs/codex/filters/wpdiscuz_delete_all_content Use this filter to set a custom expiration time in seconds for verification keys. The example sets the expiration to one day using DAY_IN_SECONDS. ```php add_filter("wpdiscuz_delete_all_content", function ($seconds) { return DAY_IN_SECONDS; }); ``` -------------------------------- ### wpdiscuz_before_load Filter Source: https://wpdiscuz.com/docs/codex/filters/wpdiscuz_wp_admin_pages This filter is applied before wpDiscuz is loaded. ```APIDOC ## wpdiscuz_before_load Filter ### Description Fires before wpDiscuz plugin is loaded. ### Parameters - None ### Returns - None ``` -------------------------------- ### Modify Avatar Link Attributes in wpDiscuz Source: https://wpdiscuz.com/docs/codex/filters/wpdiscuz_avatar_link_attributes Use this filter to change attributes of the link surrounding the avatar. For example, to remove the 'target' attribute, preventing the link from opening in a new tab. ```php add_filter("wpdiscuz_avatar_link_attributes", function ($attrs) { $attrs["target"] = ""; return $attrs; }); ``` -------------------------------- ### Add Allowed Tag with wpdiscuz_allowedtags Source: https://wpdiscuz.com/docs/codex/filters/wpdiscuz_allowedtags Use this filter to add new HTML tags to the allowed list for comment content. For example, to allow the 'wbr' tag, add it to the `$allowedtags` array. ```php add_filter("wpdiscuz_allowedtags", function ($allowedtags) { $allowedtags["wbr"] = true; return $allowedtags; }); ``` -------------------------------- ### wpdiscuz_option_page Source: https://wpdiscuz.com/docs/codex/actions/wpdiscuz_option_page This action is triggered within the wpDiscuz options page. ```APIDOC ## Action: wpdiscuz_option_page ### Description This action hook is fired within the administrative options page for wpDiscuz. It allows developers to add custom sections, fields, or functionality to the settings page. ### Usage ```php do_action( 'wpdiscuz_option_page' ); ``` ``` -------------------------------- ### wpdiscuz_dynamic_css Source: https://wpdiscuz.com/docs/codex/actions/wpdiscuz_dynamic_css This action is related to dynamically generating CSS for wpDiscuz. It is part of the available actions in the wpDiscuz 7 API. ```APIDOC ## wpdiscuz_dynamic_css ### Description This action hook is used within the wpDiscuz plugin to dynamically generate CSS styles. It allows for customization and integration of styles based on various conditions or settings. ### Usage This is an action hook that can be used by developers to hook into the dynamic CSS generation process of wpDiscuz. ### Example ```php add_action( 'wpdiscuz_dynamic_css', 'my_custom_dynamic_css' ); function my_custom_dynamic_css( $css_data ) { // Add custom CSS rules or modify existing ones $custom_css = ".wpdiscuz-container { border: 1px solid red !important; }"; return $css_data . $custom_css; } ``` ``` -------------------------------- ### Using wpdiscuz_before_save_commentmeta Hook Source: https://wpdiscuz.com/docs/codex/actions/wpdiscuz_before_save_commentmeta-2 This example demonstrates how to use the wpdiscuz_before_save_commentmeta hook to access and potentially modify comment meta fields before they are saved. It checks for a specific custom field and retrieves its value. ```php add_action("wpdiscuz_before_save_commentmeta", function ($comment, $fieldsBeforeSave) { if (!empty($fieldsBeforeSave["custom_field_5d2300b6413ef"]{ $value = $fieldsBeforeSave["custom_field_5d2300b6413ef"]; } }, 10, 2); ``` -------------------------------- ### wpDiscuz Front Scripts Actions Source: https://wpdiscuz.com/docs/codex/actions/wpdiscuz_front_scripts This section lists various actions related to wpDiscuz front-end scripts that developers can use for customization and integration. ```APIDOC ## wpdiscuz_front_scripts Actions ### Description This section lists various actions related to wpDiscuz front-end scripts that developers can use for customization and integration. ### Available Actions: - wpdiscuz_send_email_on_approving - wpdiscuz_settings - wpdiscuz_show_comments_left - wpdiscuz_show_field_for_user - wpdiscuz_social_login_response - wpdiscuz_sorting_buttons_array - wpdiscuz_source_to_image_conversion - wpdiscuz_thread_end - wpdiscuz_uploads_folder - wpdiscuz_user_can_view_field - wpdiscuz_user_can_view_fields - wpdiscuz_user_info_and_logout_link - wpdiscuz_user_label - wpdiscuz_user_role_can_comment - wpdiscuz_user_role_can_see_comments - wpdiscuz_user_settings_button - wpdiscuz_username_classes - wpdiscuz_validate_nonce_for_guests - wpdiscuz_walker_include - wpdiscuz_wp_admin_pages ``` -------------------------------- ### Restrict Guest Emails to Existing User Emails Source: https://wpdiscuz.com/docs/codex/actions/wpdiscuz_before_wp_new_comment Use this snippet to prevent guests from using email addresses already registered with a user account. This hook is available starting from version 7.6.28. ```php add_action("wpdiscuz_before_wp_new_comment", function($commentdata){ if (!empty($commentdata["comment_author_email"]) && empty($commentdata["user_id"])) { $is_user_exist = get_user_by("email", sanitize_text_field($commentdata["comment_author_email"])); if ($is_user_exist) { wp_die(esc_html__("A user with this email is already registered! Please log in or use a different one!", "wpdiscuz")); } } }); ``` -------------------------------- ### wpdiscuz_form_init Source: https://wpdiscuz.com/docs/codex/actions/wpdiscuz_form_init This action hook is executed when the comment form is being initialized. It provides access to the form object, allowing you to modify or read its properties. Available since version 7.0.0. ```APIDOC ## wpdiscuz_form_init ### Description This hook works when the form is being inited. ### Parameters * **$form** (wpdFormAttr\Form object) - the object of the inited form ### Usage ```php add_action("wpdiscuz_form_init", function ($form) { $isUserCanComment = $form->isUserCanComment; }); ``` ### Changelog Since 7.0.0 version ``` -------------------------------- ### Filter New Comment IDs in Bubble Source: https://wpdiscuz.com/docs/codex/filters/wpdiscuz_bubble_new_comment_ids Use this filter to modify the array of new comment IDs before they are displayed in the comment bubble. This example limits the number of new comments shown for a specific post. ```php add_filter("wpdiscuz_bubble_new_comment_ids", function ($newCommentIds, $postId, $currentUser) { if ($postId == 57) { $newCommentIds = array_slice($newCommentIds, 0, 5); } return $newCommentIds; }, 10, 3); ``` -------------------------------- ### wpdiscuz_form_init Filter Source: https://wpdiscuz.com/docs/codex/filters/wpdiscuz_wp_admin_pages This filter is applied during the initialization of the comment form. ```APIDOC ## wpdiscuz_form_init Filter ### Description Filters the data and settings used to initialize the comment form. ### Parameters - **$form_data** (array) - The data used for form initialization. ### Returns - (array) - The modified form initialization data. ``` -------------------------------- ### Execute Action on wpDiscuz Update Source: https://wpdiscuz.com/docs/codex/actions/wpdiscuz_check_version Use this hook to perform custom actions when the wpDiscuz plugin is updated. It checks the current plugin version against a specified version and executes custom actions if the installed version is older. ```php add_action("wpdiscuz_check_version", function () { $pluginData = get_plugin_data(__FILE__); if (version_compare($pluginData["Version"], $this->version, ">")) { $this->custom_actions(); } }); ``` -------------------------------- ### wpDiscuz Actions Source: https://wpdiscuz.com/docs/codex/actions/comment_main_form_bar_top A list of actions available in the wpDiscuz 7 API that can be hooked into for customization. ```APIDOC ## wpDiscuz Actions This section lists the available actions that can be used to hook into wpDiscuz functionality. ### Available Actions: - `wpdiscuz_send_email_on_approving` - `wpdiscuz_settings` - `wpdiscuz_show_comments_left` - `wpdiscuz_show_field_for_user` - `wpdiscuz_social_login_response` - `wpdiscuz_sorting_buttons_array` - `wpdiscuz_source_to_image_conversion` - `wpdiscuz_thread_end` - `wpdiscuz_uploads_folder` - `wpdiscuz_user_can_view_field` - `wpdiscuz_user_can_view_fields` - `wpdiscuz_user_info_and_logout_link` - `wpdiscuz_user_label` - `wpdiscuz_user_role_can_comment` - `wpdiscuz_user_role_can_see_comments` - `wpdiscuz_user_settings_button` - `wpdiscuz_username_classes` - `wpdiscuz_validate_nonce_for_guests` - `wpdiscuz_walker_include` - `wpdiscuz_wp_admin_pages` These actions allow developers to extend or modify the default behavior of wpDiscuz by adding custom functions. ``` -------------------------------- ### wpdiscuz_follow_added Source: https://wpdiscuz.com/docs/codex/actions/wpdiscuz_follow_added This action hook is fired after a user has been successfully added to the follow list. It can be used to perform additional actions, such as sending a confirmation email or updating user-specific data. ```APIDOC ## wpdiscuz_follow_added ### Description This action hook is fired after a user has been successfully added to the follow list. It can be used to perform additional actions, such as sending a confirmation email or updating user-specific data. ### Parameters This hook does not accept any parameters directly, but it is typically used within the context of a user following another user or a comment. ### Example Usage ```php add_action( 'wpdiscuz_follow_added', 'my_custom_follow_action' ); function my_custom_follow_action( $user_id, $followed_user_id ) { // Perform custom actions here, e.g., log the event or send a notification. error_log( "User {$user_id} started following user {$followed_user_id}." ); } ``` ``` -------------------------------- ### wpdiscuz_social_login_response Source: https://wpdiscuz.com/docs/codex/filters/wpdiscuz_social_login_response The wpdiscuz_social_login_response filter hook is used to modify the data returned after a social login attempt. Developers can use this hook to alter the response before it's processed further, for example, to add custom data or modify existing fields. ```APIDOC ## wpdiscuz_social_login_response ### Description Allows modification of the social login response data. ### Usage ```php add_filter( 'wpdiscuz_social_login_response', 'your_callback_function', 10, 3 ); ``` ### Parameters - **$response** (array) - The social login response data. - **$user_id** (int) - The ID of the logged-in user. - **$social_network** (string) - The social network used for login (e.g., 'facebook', 'google'). ### Return Value (array) - The modified social login response data. ``` -------------------------------- ### wpDiscuz 7 API Actions Source: https://wpdiscuz.com/docs/codex/actions/comment_main_form_after_head A list of callable functions within the wpDiscuz 7 API. ```APIDOC ## wpDiscuz 7 API Actions This section lists the available functions that can be called directly within the wpDiscuz 7 API. ### Available Actions: - `wpdiscuz_send_email_on_approving` - `wpdiscuz_settings` - `wpdiscuz_show_comments_left` - `wpdiscuz_show_field_for_user` - `wpdiscuz_social_login_response` - `wpdiscuz_sorting_buttons_array` - `wpdiscuz_source_to_image_conversion` - `wpdiscuz_thread_end` - `wpdiscuz_uploads_folder` - `wpdiscuz_user_can_view_field` - `wpdiscuz_user_can_view_fields` - `wpdiscuz_user_info_and_logout_link` - `wpdiscuz_user_label` - `wpdiscuz_user_role_can_comment` - `wpdiscuz_user_role_can_see_comments` - `wpdiscuz_user_settings_button` - `wpdiscuz_username_classes` - `wpdiscuz_validate_nonce_for_guests` - `wpdiscuz_walker_include` - `wpdiscuz_wp_admin_pages` ### Usage These functions can be invoked directly within your WordPress theme or plugin code where the wpDiscuz 7 API is accessible. Refer to specific function documentation for detailed parameter and return value information. ``` -------------------------------- ### Filter New Comment IDs for Live Update Source: https://wpdiscuz.com/docs/codex/filters/wpdiscuz_live_update_new_comment_ids Use this filter to modify the array of new comment IDs before they are displayed in the live update. The example shows how to limit the number of new comments displayed for a specific post. ```php add_filter("wpdiscuz_live_update_new_comment_ids", function ($newCommentIds, $postId, $currentUser) { if ($postId == 57) { $newCommentIds = array_slice($newCommentIds, 0, 5); } return $newCommentIds; }, 10, 3); ``` -------------------------------- ### Customize Half Star SVG with wpdiscuz Filter Source: https://wpdiscuz.com/docs/codex/filters/wpdiscuz_half_star_svg Use this filter to replace the default half star SVG. Ensure the SVG paths have '_wpd-star' and '_wpd-active' classes for proper coloring. This example targets post ratings. ```php add_filter('wpdiscuz_half_star_svg', function ($svg, $type, $icon) { if ($type === "post") { $svg = '...'; // Your custom SVG code here } return $svg; }); ``` -------------------------------- ### Enable "My Content and Settings" Button Source: https://wpdiscuz.com/docs/codex/filters/wpdiscuz_enable_content_modal Use this filter to enable the "My Content and Settings" button when default tabs are disabled. The filter expects a boolean value. ```php add_filter("wpdiscuz_enable_content_modal", function ($enable) { return true; }); ``` -------------------------------- ### wpdiscuz_username_classes Source: https://wpdiscuz.com/docs/codex/actions/wpdiscuz_editor_modules Applies CSS classes based on username or user role. ```APIDOC ## wpdiscuz_username_classes ### Description This function generates CSS classes to be applied to elements based on the username or the role of the user, allowing for custom styling. ### Method Function ### Endpoint N/A (Server-side function) ### Parameters - **user_id** (int) - Optional - The ID of the user. If not provided, the current user is assumed. ### Request Example N/A ### Response String: A space-separated string of CSS classes. ``` -------------------------------- ### Change Full Star SVG with wpdiscuz_full_star_svg Source: https://wpdiscuz.com/docs/codex/filters/wpdiscuz_full_star_svg Use this filter to replace the default full star SVG. Ensure the '_wpd-star_' class is present on the SVG paths for proper coloring. This example shows how to change the SVG for post ratings. ```php add_filter('wpdiscuz_full_star_svg', function ($svg, $type, $icon) { if ($type === "post") { $svg = '; } return $svg; }); ``` -------------------------------- ### Change Author Avatar Field Source: https://wpdiscuz.com/docs/codex/filters/wpdiscuz_author_avatar_field Use this filter to change the user ID or email used for fetching the author's avatar. The example shows how to set the avatar field to 0 for comments made by user ID 3. ```php add_filter("wpdiscuz_author_avatar_field", function ($authorAvatarField, $comment, $user, $profileUrl) { if ($comment->user_id == 3) { $authorAvatarField = 0; } return $authorAvatarField; }, 10, 4); ``` -------------------------------- ### Enable Nonce Validation for Guests Source: https://wpdiscuz.com/docs/codex/filters/wpdiscuz_validate_nonce_for_guests Use this filter to enable nonce validation for guest users. The default behavior is true, meaning validation is enabled. ```php add_filter("wpdiscuz_validate_nonce_for_guests","__return_true") ``` -------------------------------- ### wpdiscuz_check_version Source: https://wpdiscuz.com/docs/codex/actions/wpdiscuz_check_version This action is triggered to check the version of wpDiscuz. It can be used for compatibility checks or to perform version-specific tasks. ```APIDOC ## wpdiscuz_check_version Action ### Description This action hook is used within the wpDiscuz plugin to facilitate version checking. Developers can use this hook to ensure compatibility or to trigger specific logic based on the plugin's version. ### Usage ```php do_action( 'wpdiscuz_check_version' ); ``` ``` -------------------------------- ### Display Custom HTML Below Comment Form (PHP) Source: https://wpdiscuz.com/docs/codex/actions/wpdiscuz_form_bottom Use this action to add custom HTML content below the comment form. The callback function receives parameters indicating if it's the main form and details about the form, user, and comment count. This example shows conditional messages based on whether it's the main form. ```php add_action("wpdiscuz_form_bottom", function ($isMain, $form, $currentUser, $commentsCount, $uniqueId) { if ($isMain) { echo "Custom Message Form Main Form"; } else { echo "Custom Message Form Secondary Form"; } }, 10, 5); ```