Tag Info

New answers tagged

0

Any ideas anyone? Ive tried to run same array and foreach but for user_id => 1, to test. But all I get is a complete list with comments made by user with id 1. I want to display only the responses (from user id 1) below the current_user comments.


0

Have you tried $subscriber= get_role('subscriber'); $subscriber->add_cap('edit_comment'); NOTE eidt_comment is only supported in verson 3.1 or later This worked for me , hope it helps you!


1

I found a soloution and what causes it. It was not really the delimiter that was the problem it was becasue a user made duplicate posts. Solution: Replace $notify_message .= preg_replace('#[\s]+#', ' ',sprintf( get_comment_meta($comment->comment_ID, 'title',1))) .' skrev:'. "\r\n" . $comment->comment_content . "\r\n\r\n"; With ...


1

Your comments.php is included multiple times for some reason. Look for comments_template() – maybe it is called too early. Each time that happens, PHP tries to create the function comment_theme() again. This cannot work, function names must be unique. Move the function declaration to the functions.php. So everything including … <?php function ...


1

You could try this to skip comments made by user with user_id = 1 in the Recent Comments widget: add_action( 'widgets_init', 'custom_recent_comments' ); function custom_recent_comments(){ add_filter( 'comments_clauses', 'custom_comments_clauses' ); } where function custom_comments_clauses( $clauses ){ $clauses['where'] .= " AND user_id != 1 "; // ...


2

You can store the data in the user meta as an array of post-id -> comment count at last visit and then simply count the comments since that date, for example function get_user_comment_count_since_last_visit($user_id ,$post_id){ //only do this for logged in users if ($user_id <= 0 ){ return 0; } /** * get last comment count ...


1

Actually you can include the editor-style.css (or any other stylesheet), just pass a "content_css" value to tinymce that points to a css file: wp_editor( $content, 'editablecontent', array( 'tinymce' => array( 'content_css' => get_stylesheet_directory_uri() . '/editor-styles.css' ) ); So the original ...


0

WordPress should give this option below Attribute all posts to: Anyhow, I wrote a post on this (Clean Comments Table After User Deleted) Edit Also, you can move your all posts from deleted users to admin user. global $wpdb; $admin_id = 1; // Assign admin user id here $posts_table = $wpdb->prefix . 'posts'; $users_table = $wpdb->prefix . 'users'; ...


0

From inside a comment Loop... $author_data = get_user_by('login',$comment->comment_author); if (!empty($author_data)) { var_dump($author_data->roles); } $author_data->roles is an array so you will need to work out what you want to do with that. That is, print them all? Print the highest ranking role? if ...


2

http://codex.wordpress.org/Function_Reference/get_comments#Parameters your problem is using author_email, you need user_id i just use similar script. <?php $args = array( 'user_id' => $user->ID, 'number' => 10, // how many comments to retrieve 'status' => 'approve' ); $comments = get_comments( $args ...


0

Check This Show Comments by User ID in WordPress


1

You can try this query that counts user comments by using the user_id field in the comments table as a filter: function count_user_comments_today( $uid ){ global $wpdb; $today = date('Y-m-d'); $tomorrow = date('Y-m-d', time() + 86400); $count = $wpdb->get_var( $wpdb->prepare("SELECT COUNT(*) FROM {$wpdb->comments} WHERE user_id = %d ...


1

I don't know of a way to directly pull this query with Core functions, but the SQL is simple. $sql = "SELECT COUNT(comment_ID) FROM {$wpdb->comments} WHERE comment_author = 'admin' AND DATE(comment_date) = FROM_UNIXTIME('".time()."')"; $a = $wpdb->get_var($sql); You can alternately use something like AND DATE(comment_date) ...


1

Yes it's definitely possible. Refer to http://codex.wordpress.org/Function_Reference/get_comment, you'll need to get the current server time in UNIX format and then convert comment_date_gmt from each returned be using a foreach loop function current_user_comments_today() { global $comment; global $current_user; get_currentuserinfo(); $all_user_comments ...


0

A gallery is a post with attached media. So maybe you'll find hints like this : just hook on get_comment_numbers() and pass $attachment_id. I think in this case you'll have to add an SQL query to get the comment count for attachment and then you'll be able to add it to the total number of comments for post , something like this : global $wpdb; ...


1

The database table that WordPress uses to store its comments has a couple date fields in it -- comment_date and comment_date_gmt. You should be able to do something like this: function wpse99287_comment_count( $content ) { global $wpdb; global $post; $today = date( 'Y-m-d 00:00:00' ); $tomorrow = date( 'Y-m-d 23:59:59' ); $sql = "SELECT ...


3

There is no argument to restrict a comment query directly to a given date. You have to filter the query later: /** * Get the number of comments for a post today. * * @param int $post_id * @return int */ function t5_count_comments_today( $post_id = NULL ) { if ( NULL === $post_id ) $post_id = get_the_ID(); add_filter( ...


0

Add style=ol to your call to wp_list_comments. Reference: http://codex.wordpress.org/Function_Reference/wp_list_comments#Parameters


3

To print just the total number of comments for a given post ID, use the count argument: echo get_comments( array ( // post ID 'post_id' => 149, // return just the total number 'count' => TRUE ) ); To get the total number of all comments of all posts on the current page, you can use the comment_count property ...


1

You can use get_page_by_title http://codex.wordpress.org/Function_Reference/get_page_by_title to check if another page/post is using the same title. If so, get the content of that post and insert it using wp_insert_comment, and delete the original post with wp_delete_post. Finally, glue all these together inside the save_posts action hook.


1

This is how I've handled passing messages back to the user before: within your current function, set a transient with your message: set_transient( 'admin_notice', 'Please put down your weapon. You have 20 seconds to comply.' ); Then add a new hooked function: function admin_notices() { $notice = get_transient( 'admin_notice' ); if ( $notice ) { ...


1

ok.. so I did it like this. Maybe will help some. Used the code from Last comment page first with full number of comments? but altered it a bit to fit my needs. So this goes into your template page where you call the comments (or you can wrap it in a function and put it into functions.php) <?php comments_template( '', true ); ?> <?php ...


0

In wp-admin, go to Settings -> Discussion -> Break comments into pages with X top level comments per page and the FIRST page displayed by default. If you pick the first page displayed by default make sure the drop-down underneath is set to OLDER comments at the top of each page.


1

Filter the 'comments_open' check. It happens inside of the function with the same name, and that function is called in a theme usually like this: comments_open() and comment_form( array ( 'comment_notes_after' => '' ) ); This is how the filter works: add_filter( 'comments_open', 'wpse_98775_comment_check', 10, 2 ); function ...


0

You may have turned off commenting on upcoming posts. The posts that already exists will not be affected. may be. You could probably search on how to turn off commenting in posts that have already been posted. mbBlogging


-2

I personally feel that its just coz you may have put some links in beginning in your comments, and they were marked as spam. Ask the blog owner to restore your comments. I also got the same problem when i use to comment on other blogs for the promotion of my blog and to overcome i stopped commenting for some days. And now its okay.


2

You could also use the hook pre_comment_on_post to exit early: add_action( 'pre_comment_on_post', '_scalar_wp_die_handler' ); This will not change the database.


1

If you have unchecked Allow people to post comments on the article on the Options > Discussion panel, then you have only disabled comments on future posts. To completely disable comments, you will have to edit each past post and uncheck Allow Comments from the Write Post SubPanel. Alternatively, you could delete the wp-comments-post.php file, or run this ...


0

Have you tried removing them from the template? Look for <?php comments_template(); ?> and comment it out in single-listings.php.


0

You could create a hidden dummy post and use always its post ID as comment_post_ID. Then use a comment meta field to store the related ID from your custom table. The other, and probably better option: use custom post types, not tables if you need something that acts like a post. Register that post type with … 'supports' => array( 'comments', ), … ...


0

I just did a quick test and the comment blacklist appears to be ignored for logged in administrators (possibly other roles). It does effectively block comments when logged in as a subscriber. I suspect that that is the behavior you are seeing.


2

Your PHP is wrong but what you are doing looks like it should work. $count = $wpdb->get_var( 'SELECT COUNT(distinct comment_author) FROM ' .$wpdb->comments. ' WHERE comment_approved = 1 AND comment_post_ID = '.$post->ID ); echo $count; Precisely, you were trying to use a variable inside single quotes, which doesn't work. ...


2

The asker solved the issue with $_SERVER["HTTP_REFERER"] but refused to post that as a real solution. Let me suggest something better, because the referer might be empty or full of malicious code. Never use that. First, we make sure, we get both arguments for that hook: add_filter( 'comment_post_redirect', 'wpse_97580_comment_redirect', 10, 2 ); Then we ...


1

Figured it out. Looking at wp-comments-post.php there is a filter called comment_post_redirect which I used to check if the comment was approved and then added a query string to the URL. So easy. //A query string needs to be added when redirecting back to the post after a comment is posted and not approved. This ensures the page with the "Your comment is ...


2

Looking at the Codex entry for get_comment_meta(), it appears that when the $single argument is set to TRUE (as you have done), the function returns a string. Try throwing an echo() into the works: <?php echo get_comment_meta( $comment->comment_ID, 'country', true ); ?>


4

Assuming you'd like the facility to update this data from the quickedit box whilst viewing the list of comments, you'll need a series of actions and filters. I've tried to make appropriate comments in the necessary places for you, though bear in mind i threw this all together for you with a small amount of testing(it does work though). This should get give ...


3

If you prefer simple template files, you can do that with custom comment callbacks too. Call wp_list_comments() with a custom callback handler: wp_list_comments( array( 'callback' => 'custom_comment_callback', 'style' => 'ol' ) ); Now make that callback function very simple: function custom_comment_callback( ...


0

There are quite a bit of plugins available to do this for you, a quick Google search will get you there. Bloglist, recent posts and comments from the whole network. Can be found here. A central area where all the posts on a WordPress MU or WordPress MS site can be collected. Can be found here. A list of premium plugins (one matching ...


0

Disqus pre-moderation rules are set on http://disqus.com/admin/settings/ and can't be administered via Wordpress. Currently there are only options to pre-moderate all comments, or comments from unverified users globally. If you wanted this kind of granularity, you can always register a new Disqus shortname (which is a container for all of your ...



Top 50 recent answers are included