Support

Search results for ""

Sorry, no results found. Perhaps you would like to search the documentation?
All Topics
Laura Hammond

add new comments in bulk edit mode?

Is there a way to allow an admin to create new comments on a bunch of selected posts in bulk edit mode? I have written a custom code snippet that creates a comment when my CPT approval status changes, and that works in bulk edit mode, but I would like to have something like a “new comment” column where we could type in one comment and submit it to each of the selected CPTs.

Also, I am using Pods, so that may play into things…

Any suggestions for the best way to make this happen?

Thanks!

4 months, 2 weeks ago
Laura Hammond

Oh, alternately, instead of displaying a column to type in new comments, we could have a dialog box pop up whenever the approval status changes, allowing an admin to post the reason for the change (which would get saved as a comment). If that is easier to do, please let me know if there are any code samples to assist with that, too. Thanks!

4 months, 2 weeks ago
Stefan van den Dungen Gronovius
Developer

Hi Laura,

It seems like you have a very specific use case and our plugin does not offer a solution for this out of the box. I guess that the best solution for you is to write your own custom column to trigger the logic you already have to create a comment. Since that column probably won’t need any of our pro logic, you could use the default WordPress hooks to write the column. You could find an article on how to do this here:

https://www.smashingmagazine.com/2017/12/customizing-admin-columns-wordpress/

4 months ago
Laura Hammond

I have been following some tutorials to add new fields to the bulk Quick Edit form, and I have some aspects of it working, but it appears to be clashing with some of the code or features in AdminColumnsPro.

Specifically, I have followed the instructions in this tutorial: https://rudrastyh.com/wordpress/bulk-edit.html.
but it isn’t quite working for my custom post type (which was created with Pods).

Do you have developer documentation that explains how to add the Bulk Edit buttons for a custom column?

4 months ago
Laura Hammond

More details: when I use the tutorial instructions to add a new field to the Quick Edit panel of posts, it works. But when I try to add it to my custom post type, I get this notice:
Notice: Trying to get property ‘name’ of non-object in /public_html/wp-content/plugins/admin-columns-pro/admin-columns/classes/Settings/Column/Term.php on line 78

So I gather that the admin list view of my CPT doesn’t recognize the simple column I added like this:


// my custom post type is called 'activity_log_item' 
add_filter( 'manage_activity_log_item_posts_columns', 'new_comment_option_in_quick_edit_add_columns' );
function new_comment_option_in_quick_edit_add_columns( $column_array ) {
	$column_array[ 'new_comment' ] = 'New Comment';			
	return $column_array;
}

So the question is: how do I add a field to the Quick Edit View when I’m using Admin Columns Pro?

Also, I tried to add the new comments field as below, but then when I choose Edit from under the Bulk Actions drop down and click Apply, nothing happens. The normal bulk edit form view does not show up. And when I click Quick Edit on an individual custom post type item, my new field is not showing, either.

add_action( 'bulk_edit_custom_box',  'misha_quick_edit_fields', 10, 2 );
add_action( 'quick_edit_custom_box',  'misha_quick_edit_fields', 10, 2 );

function misha_quick_edit_fields( $column_name, $post_type ) {

	switch( $column_name ) {
		case 'new_comment': {
			?>
				<fieldset class="inline-edit-col-left">
					<div class="inline-edit-col">
						<label>
							<span class="title">Add New Comment:</span>
							<textarea name="new_comment"></textarea>
						</label>
					</div>
				<?php
			break;
		}

	}
}
4 months ago
Stefan van den Dungen Gronovius
Developer

It is good that there are two different things:

1) Bulk Edit in the Bulk actions menu. This is not a feature provided by our plugin. All code snippets you’re using are example on how to add all functionality to the WordPress ecosystem by default.

2) There are the Bulk Edit button on top of the table provided by our plugin. All code snippets should not affect anything happening in that row.

Since you’ve chosen to go the default WordPress path (suggested in my previous post), there is not much support I can give you on the code you’ve written so far. It also seems that the warning that you see if your log file is not related to the custom code.

I believe that the columns must be added to the table in order to see it in the Quick Edit and Bulk Edit form, so you’ll need to make sure the column is added to the table with our plugin as described above.

When you have written your custom column, you should be able to see and manage the column (order, width, etc) with ou plugin. When you add a new column with our plugin, you should be able to see the ‘New Comment’ column in the ‘Default’ section.

4 months ago

You must be logged in to reply to this topic.