rest_pre_insert_comment

過濾鉤子
apply_filters( 'rest_pre_insert_comment', $prepared_comment, $request )
引數
  • (array|WP_Error) $prepared_comment The prepared comment data for wp_insert_comment().
    Required:
  • (WP_REST_Request) $request Request used to insert the comment.
    Required:
定義位置
相關勾子
rest_insert_commentrest_after_insert_commentwp_insert_commentrest_pre_insert_userrest_prepare_comment
相關方法
wp_insert_commentget_page_of_commentwp_list_commentswp_new_commentget_previous_comments_linkwp_filter_comment
引入
4.8.0
棄用
-

rest_pre_insert_comment – 這個鉤子用於在評論插入資料庫之前修改它的資料。每當一個評論通過REST API提交,在插入資料庫之前,這個鉤子就會被觸發。它為開發者提供了一種方法來修改提交給API的評論的資料。

在通過REST API插入評論之前對其進行過濾。

允許在通過wp_insert_comment()插入評論前對其進行修改。從過濾器返回WP_Error值將縮短插入的時間,並允許跳過進一步的處理。

Plain text
Copy to clipboard
Open code in new window
EnlighterJS 3 Syntax Highlighter
$prepared_comment = apply_filters( 'rest_pre_insert_comment', $prepared_comment, $request );
$prepared_comment = apply_filters( 'rest_pre_insert_comment', $prepared_comment, $request );
$prepared_comment = apply_filters( 'rest_pre_insert_comment', $prepared_comment, $request );

常見問題

FAQs
檢視更多 >