Filter hook for the action of listing users

Just like posts with WP_Query and pre_get_posts, there is WP_User_Query and pre_get_users that lets you modify the query parameters for fetching the users. This is the most efficient method of adjusting the list of users. e.g. add_action( ‘pre_get_users’, ‘justin_wylllie_pre_get_users’ ); function justin_wylllie_pre_get_users( \WP_User_Query $query ): void { // … modify the query object if we’re … Read more

How to add custom field to top of WordPress Comment Form for both logged in and anon users

I think you could use the comment_form_field_comment() filter to add the custom HTML before the main comment field. The filter is fired for both visitors and loggedin users. add_filter( ‘comment_form_field_comment’, ‘wpse_426971_comment_form_field_before’ ); function wpse_426971_comment_form_field_before( string $field ): string { return sprintf( ‘<p>%s</p>%s’, is_user_logged_in() ? “I’m logged in” : “I’m not logged in”, $field ); } … Read more

tech