Menu Adam R Brown

WP hooks navigation: Home/browseActions indexFilters index

Source View: rest_allow_anonymous_comments

To save our bandwidth, we show only a snippet of code around each occurence of the hook. View complete file in SVN (without highlighting).

Understanding Source Code

The best way to understand what a hook does is to look at where it occurs in the source code.

Remember, this hook may occur in more than one file. Moreover, the hook's context may change from version to version.

Source View

Line Code
467                 * Enables creating comments for anonymous users.
468                 *
469                 * @since 4.7.0
470                 *
471                 * @param bool $allow_anonymous Whether to allow anonymous comments to
472                 *                              be created. Default `false`.
473                 * @param WP_REST_Request $request Request used to generate the
474                 *                                 response.
475                 */
476                $allow_anonymous = apply_filters( 'rest_allow_anonymous_comments', false, $request );
477
478                if ( ! $allow_anonymous ) {
479                     return new WP_Error(
480                          'rest_comment_login_required',
481                          __( 'Sorry, you must be logged in to comment.' ),
482                          array( 'status' => 401 )
483                     );
484                }
485           }