Making a Comment on a page without being on that page?

You have to set the value of $_POST[‘comment_post_ID’] to the post id of the page: <input type=”hidden” name=”comment_post_ID” value=”10″ /> Then set the action of the form element to /wp-comments-post.php, filter ‘comment_post_redirect’ and send the visitor back to page where the comment/review was written. Here is an example, written as plugin: <?php /* Plugin Name: … Read more

How to disable empty tags in comment_text()

If you look in wp-includes/default-filters.php you’ll see all of the functions each comment is run through before it’s output. I’d guess it’s the last one, wpautop, which adds p tags in place of line breaks: add_filter( ‘comment_text’, ‘wptexturize’ ); add_filter( ‘comment_text’, ‘convert_chars’ ); add_filter( ‘comment_text’, ‘make_clickable’, 9 ); add_filter( ‘comment_text’, ‘force_balance_tags’, 25 ); add_filter( ‘comment_text’, … Read more

Only subscriber role user can comment not other

I suggest adding a snippet to the theme file where the comments form is loaded that checks to make sure there is a logged in user and then, if that user a Subscriber, then show the comments form to them. The examples below use the Twenty Sixteen theme: In comments.php: // First, get the current … Read more

How to make comment text field un-required?

You can circumvent the check for empty comments easily by adding the uploaded image as HTML to the comment text: add_action( ‘pre_comment_on_post’, ‘allow_empty_comment_text’ ); function allow_empty_comment_text( $text=”” ) { if ( ! isset ( $_POST[‘comment’] ) or ” === trim( $_POST[‘comment’] ) ) { $img = ‘/* Process uploaded image here, create an <img> tag. … Read more

Add delete, approve, spam Links to Comments

Per default wp_list_comments() calls the class Walker_Comment. Its method start_el() calls edit_comment_link() and here we find a filter for your question: It is called ‘edit_comment_link’ and it passes two variables, the link text and the comment ID, which we can use. The URLs to mark a comment as spam or to delete it are: wp-admin/comment.php?c=1&action=cdc&dt=spam … Read more

Average Score of all ratings in comments

add this code into your plugin file to register activation hook // register activation hook register_activation_hook( __FILE__, ‘my_rating_plugin_activation’ ); now create a function and add your table creation code into function my_rating_plugin_activation() { global $wpdb, $rating_table_name; if($wpdb->get_var(“SHOW TABLES LIKE \”$rating_table_name\””) != $rating_table_name) { $wpdb->query(“CREATE TABLE IF NOT EXISTS $rating_table_name ( rating_id int(11) NOT NULL AUTO_INCREMENT, … Read more

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