wp_insert_comment and security

wp_insert_comment() is low level function, it only saves passed data without concern for what it contains. If you are looking to replicate sanitizing WP does on comment data (totally good idea 🙂 you are probably looking for higher level wp_new_comment().

Cannot get local avatars to show [closed]

Debug ideas: You could try to see if this has any effect: add_filter( ‘bp_core_fetch_avatar_no_grav’, ‘__return_true’ ); But you should check out the parameters that go through the bp_core_fetch_avatar filter to see if they are correct (untested): add_filter( ‘bp_core_fetch_avatar’, ‘my_bp_core_fetch_avatar’, 99, 9 ); function my_bp_core_fetch_avatar( $html, $params, $item_id, $avatar_dir, $css_id, $html_width, $html_height, $avatar_folder_url, $avatar_folder_dir ) { … Read more

Removing from Comment

wp_list_comments() accepts a walker in the array of its first parameter. This is a class that renders the output. If you don’t provide one, the default class will be used, Walker_Comment. You can find it in wp-includes/comment-template.php. To change the complete comment list out, create a custom walker in your functions.php which extends the default … Read more

Add classname comment template from functions.php

You should consider hooking into the comment_class() and post_class() filters, if your theme supports it. Using the comment_class filter: We can add the following filter: /** * Add a custom comment class, based on a given comment author’s user meta field. * * @see http://wordpress.stackexchange.com/a/170443/26350 */ add_filter( ‘comment_class’, function( $classes, $class, $comment_id, $post_id ) { … Read more

Change username to nickname in comment section

Yes, of course it won’t show any name for guest comments because they are not registered users of your website so they don’t have any nickname associated. What you can do in this situation, is add a check before printing the nickname, if comment was made by a user or a guest. And act accordingly. … Read more

Comment form connection to Gravity Forms

This is possible using the comment_post action, and the GFAPI class which handles entries in WordPress. What you need to first is add using comment_form_default_fields a field which is a checkbox. function add_to_email_list_field($fields) { $fields[‘add-to-email’] = ‘<p class=”comment-form-public”> <input id=”addtoemail” name=”addtoemail” type=”checkbox” /> <label for=”addtoemail”> Check this box to add yourself to our email list. … Read more

How to add replyToUrl schema.org to WordPress comments?

You could instead try the following replacement: /** * Add itemprop attribute to the comment reply link */ add_filter(‘comment_reply_link’, function( $html ) { if( false === stripos( $html, ‘itemprop=”‘ ) ) $html = str_ireplace( ‘<a ‘, ‘<a itemprop=”replyToUrl” ‘, $html ); return $html; }, 99 ); through the comment_reply_link filter. The HTML generation, of the … Read more

Hata!: SQLSTATE[HY000] [1045] Access denied for user 'divattrend_liink'@'localhost' (using password: YES)