WordPress.org

Ready to get started?Download WordPress

Forums

Edit Flow
[resolved] New feature request: editors (12 posts)

  1. dsals
    Member
    Posted 1 year ago #

    Thank you for a wonderful plugin.

    I would love to be able to assign editors to posts, and to have those editors show up as a column in the post table just like authors, sortable in the same fashion. It's important for us to be able to track which articles specific editors have been working on. I'm guessing others have this need as well.

    http://wordpress.org/extend/plugins/edit-flow/

  2. cojennin
    Member
    Plugin Author

    Posted 1 year ago #

    Sorry this is a bit late. Interesting idea. It seems like this could be partially solved by making an Editorial Metadata of a "user" type and call it something like "Editor Assigned:." The only issue would be getting it to show up on the posts table. I believe some simple tweaking with the manage_posts_custom_columns action should do it, but I don't know for sure. I'll try putting something together to see if I can get it to work.

  3. dsals
    Member
    Posted 1 year ago #

    Awesome, thanks. It's just something on my wish list. I tried to do it myself but kept breaking things :)

  4. cojennin
    Member
    Plugin Author

    Posted 1 year ago #

    Ok, so this works for me when inserted into my "functions.php" file in my theme. To clarify, I called my editorial metadata "Working on", and gave it a type of "user." That's why I'm looking for a post_meta called "_ef_editorial_meta_user_working-on". The "_ef_editorial_meta" is prepended for editorial metadata as post meta being inserted into the database. The "_user" is another string prepended because I selected a type of "user", and then "working-on" is just the name of my editorial meta data (uncapitalized and spaces replaced with dashes Ninja Edit: It might actually be the slug that's being appended, not just the name decapitalized and dashes removed. I'll double check). To double check, just save a post with the meta data of your choice and look at the database to see how it's been saved. But is should save along the lines of the formula above.

    I could not for the life of me figure out where the sortable_columns filter is applied. I'm still trying to hunt it down just cause I'm curious, but it works at making it sortable. I called my column "Editor," which you'll see in the add_editor_columns function.

    Feel free to post back here if you're having problems or if the code needs more 'splainin.

    // Getting metadata to show up on posts table
    add_action( 'manage_posts_custom_column' , 'ef_custom_column', 10, 2 );
    
    function ef_custom_column($column, $post_id) {
    	if( $column == 'editor' ) {
    		$user_id = (int)get_post_meta($post_id, '_ef_editorial_meta_user_working-on', true );
    		$editor = get_user_by('id', $user_id);
    		echo $editor->user_nicename;
    	}
    }
    
    add_filter('manage_post_posts_columns' , 'add_editor_columns');
    
    function add_editor_columns($columns) {
        return array_merge($columns,
                  array('editor' => __('Editor')));
    }
    
    add_filter( 'manage_edit-post_sortable_columns', 'make_editor_sortable' );
    
    function make_editor_sortable($columns) {
    	$columns['editor'] = 'editor';
    	return $columns;
    }
  5. Daniel Bachhuber
    Hand Built
    Plugin Author

    Posted 1 year ago #

    There's an easier way. Make the editorial metadata "visible" and it will be automatically added to the Manage Posts list table (or any list table for posts its enabled for).

  6. cojennin
    Member
    Plugin Author

    Posted 1 year ago #

    Ha. And that would make it a lot easier.

  7. cojennin
    Member
    Plugin Author

    Posted 1 year ago #

    But it doesn't make it sortable.

  8. cojennin
    Member
    Plugin Author

    Posted 1 year ago #

    So I guess just cut out everything except the sortable filter.

  9. Daniel Bachhuber
    Hand Built
    Plugin Author

    Posted 1 year ago #

    I don't think you want it sortable, but rather filterable (and that should happen automatically).

  10. dsals
    Member
    Posted 1 year ago #

    Filterable would also be fine. I was thinking sortable originally so that I could scan the whole list. But I don't mind clicking on an editor's name (or I will leave in the sorting code -- thanks fuzz).

    So -- sillyish question -- how do I "Make the editorial metadata 'visible'"?

  11. cojennin
    Member
    Plugin Author

    Posted 1 year ago #

    When you create or edit Editorial Metadata, there should be a drop-down near the bottom labeled "Viewable." Just need to select "Yes."

  12. dsals
    Member
    Posted 1 year ago #

    Wow. Super easy. Thank you both so much for your time and help!

Topic Closed

This topic has been closed to new replies.

About this Plugin

About this Topic

Tags