wphooks.info - rest_allow_anonymous_comments

rest_allow_anonymous_comments

(trunk - 5.1-alpha-44286)

The hook occurs in the following file:

wp-includes/rest-api/endpoints/class-wp-rest-comments-controller.php:
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
			 *
			 * Enables creating comments for anonymous users.
			 *
			 * @since 4.7.0
			 *
			 * @param bool $allow_anonymous Whether to allow anonymous comments to
			 *                              be created. Default `false`.
			 * @param WP_REST_Request $request Request used to generate the
			 *                                 response.
			 */
			$allow_anonymous = apply_filters( 'rest_allow_anonymous_comments', false, $request );
			if ( ! $allow_anonymous ) {
				return new WP_Error( 'rest_comment_login_required', __( 'Sorry, you must be logged in to comment.' ), array( 'status' => 401 ) );
			}
		}

		// Limit who can set comment `author`, `author_ip` or `status` to anything other than the default.
		if ( isset( $request['author'] ) && get_current_user_id() !== $request['author'] && ! current_user_can( 'moderate_comments' ) ) {
			return new WP_Error(
				'rest_comment_invalid_author',