Tag Info

Hot answers tagged

8

A standard WordPress schema "sync" via dbDelta() will only add indexes, not drop them. Same goes for fields. We never touch the storage schema either, so it'd be the default for MySQL (which in latest versions is now InnoDB). On the face, a comment_id_meta_key index makes perfect sense. But when you look at how WordPress actually uses its metadata tables, ...


7

comment_karma This field is used by a few plug-ins to help you manage your comments. There are a few good articles explaining its exact use floating around on the Internet. But you should note that this field is actually just not used. As Mark Jaquith said once, it's a "there if you want to use it this." There was a short movement to remove it for ...


7

To record the moderator that approves the comment: function wpse_comment_moderator_log( $comment ) { global $current_user; get_currentuserinfo(); update_comment_meta( $comment->comment_ID, 'approved_by', $current_user->user_login ); } add_action( 'comment_unapproved_to_approved', 'wpse_comment_moderator_log' ); To display it after the ...


5

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 ...


5

Filter comment_form_field_comment to add a select element with a label. Add a callback to the action comment_post to save the value. Filter comment_text to show the value for a comment. Sample code: add_filter( 'comment_form_field_comment', function( $field ) { global $wp_roles; $user = wp_get_current_user(); $select = ...


3

In the link you have provided it shows how to get the value of the "collected" meta using $twitter = get_comment_meta($comment_ID,'_twitter',true); so all that is left for you to do is edit your comments loop and add the next few lines in it. $extra_field = get_comment_meta($comment_ID,'_extra_field',true); echo $extra_field; Hope this Helps


3

If you need to show the averages in the content, you need to pre-calculate them (before showing the comments). My approach would be having a custom meta in the post with the calculated averages and modify those metas every time a new comment (rating) is saved. Something like add_action("comment_post", "wpse16733_updateAVGs"); function ...


3

The comment_post hook is called with a $comment_id as the first argument. You can see why your function is failing. Same goes for the edit_comment hook. Simply add the following at the beginning of your business function: if ( !is_object( $comment ) ) $comment = get_comment( $comment ); Do use a custom SQL query for comment metadata retrieval, as ...


3

Here you go: Adding Custom Fields to WordPress Comment Forms? And another awesome post on this: http://wpengineer.com/2214/adding-input-fields-to-the-comment-form/ Functions are available to add/update, delete comment meta, similar to post and user meta. Edit: Here's an example to give you a start (put the code into the functions.php or in a custom ...


3

To show the content on individual edit pages you need to add custom meta boxes to the comment edit page. You'll use the key comment for the $page argument of add_meta_box. <?php add_action( 'add_meta_boxes_comment', 'pmg_comment_tut_add_meta_box' ); function pmg_comment_tut_add_meta_box() { add_meta_box( 'pmg-comment-title', __( 'Comment Title' ), ...


2

You are not limited in this case. Just create the needed composite indexes and remove any duplicate indexes. For example: ALTER TABLE wp3_commentmeta ADD INDEX comment_id_meta_key_ndx (comment_id, meta_key); ALTER TABLE wp3_commentmeta DROP INDEX comment_id; Just make sure your queries actually uses the newly made indexes.


2

comment_karma - no idea, doesn't seem meaningful in current code; comment_type - this marks pingbacks/trackbacks, empty for normal comments; comment_approved - approval (0 or 1) and spam (spam) status. On your usage - why not just create custom post type for procedures? Comments are much less flexible than posts and kinda single-purposed in nature.


2

EDIT: With some help of a friend I came up with a solution. For everyone interested: Use a custom post-type, in my case comment_post. Then upload the images like this: $new_post = array( 'post_title' => $title, 'post_content' => $comment, 'post_status' => 'pending',// Choose: publish, preview, future, draft, etc. 'post_type' => ...


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 ); ?>


2

That table is essentially the same as for all of the other "meta" tables in the WordPress architecture. It holds misc. bits of extra, usually optional, information about the associated post, user, or in this case comment. You can store whatever information you need to add to a comment-- perhaps a plugin wants to implement "abuse" flags, or comment upvotes. ...


1

Your basic question is a pure SQL question. $count = $wpdb->get_var( 'SELECT COUNT( comments.comment_ID ) FROM '. $wpdb->comments .' as comments LEFT JOIN '.$wpdb->commentmeta.' AS cmeta ON comments.comment_ID = cmeta.comment_id WHERE user_id = 1 AND comment_approved = "1" AND comment_type NOT IN ("pingback", "trackback" ) AND ...


1

I think you only want get_comment and not get_comments on this line: $com=get_comments($comment_id); You are only checking for a single comment, by the ID. get_comments won't do that the way you are using it. There is a check halfway through the update_metadata function that compares the existing value to new value under some circumstances. That runs ...


1

This slideshow from Beau Lebens should be able to show you how: Hooking into Comments And this blog post from Otto should be able to show you more: WordPress 3.0 Theme Tip: The Comment Form There is also a basic plugin available here called "Wordpress Plugin: Extra Comment Fields" (sorry can't post the link).


1

I think you've way over-complicated things. Assuming private is a checkbox, just check for it being set, and act accordingly. With form $_POST data, a checkbox will send its value if checked, and will send nothing if not checked: if ( isset( $_POST['private'] ) ) { update_comment_meta( $comment_id, 'private', 'private' ); } else { ...


1

I've got something similar using a custom query to calculate the average on the fly - per Rabino's comment, it would be more efficient to store the result of this function as a meta value, but I'd want it triggered when a comment is approved, rather than when a comment is saved. here's your function: function average_rating() { global $wpdb; ...


1

If you look into the function comments_popup_link() you will see the following code at the end: $title = the_title_attribute( array('echo' => 0 ) ); echo apply_filters( 'comments_popup_link_attributes', '' ); echo ' title="' . esc_attr( sprintf( __('Comment on %s'), $title ) ) . '">'; comments_number( $zero, $one, $more ); echo '</a>'; // last ...


1

Karma is a relic. Unused. Agent is the browser agent of the person who left the comment. Like saying they use firefox or IE or whatever. Comment type is either "comment" (or blank for the default case) or "pingback" or "trackback", basically. You can have custom types, however they generally won't show up as comments because WP doesn't know about those ...


1

Unfortunately it's unsupported by the applicable WordPress functions for querying comments, which is primarily due to(i feel) not enough people(or anyone) yet asking for it. I want to highlight a couple of core files here to help understand the issue. First up comments-template.php, the comment_template function, it's this function that queries for ...


1

From the look at code WP_Comment_Query class, used internally by get_comments() allows orderby argument to be set to 'meta_key' string to sort by key in argument of same meta_key name.



Only top voted, non community-wiki answers of a minimum length are eligible