WordPress.org

Ready to get started?Download WordPress

Forums

Co-Authors
Co-authors not saving author info (5 posts)

  1. mbeasi
    Member
    Posted 2 years ago #

    I've been using co-authors for a long time, but since my upgrade to WP 3.1.3, it's developed a quirk I can't figure out.

    When I create a draft with multiple authors, the author information does not survive between saves. For instance, I'll create a draft, set the author names, and then save the draft. After saving, the author credit has reverted to just the first author on the list. This happens anytime the post is edited and re-saved.

    I can set the authors and then immediately publish, and it will save all authors, but if I go in to edit that post later, the information is gone again, and I have to re-add all authors just before hitting "update."

    Does anyone have insight on why this might be happening?
    This is my site.
    Here is a post with multiple authors.

  2. tess2n
    Member
    Posted 2 years ago #

    I have the same problem. Also, additional authors seem to disappear from older posts as well.

  3. primeweb
    Member
    Posted 2 years ago #

    Hello there,
    did you guys figure out why the list of co-authors is not working in the backend anymore?

  4. mbeasi
    Member
    Posted 2 years ago #

    Primeweb: I just ended up switching to co-authors plus. It was a pain initially, but worth it in the end.

  5. af.
    Member
    Posted 1 year ago #

    I've come up with a fix for this, so if you're willing to edit about with your copy of the plugin code then here's some diff patches...

    co-authors.php

    @@ -329,6 +329,7 @@
    
     function coauthors_modify_post_sidebar(){
     	global $current_user;
    +	global $post;
     	//if($current_user->has_cap('edit_others_posts')){
     		print '<script type="text/javascript">';
     		print 'var coauthors_can_edit_others_posts = ' . ($current_user->has_cap('edit_others_posts') ? 'true' : 'false') . "\n";
    @@ -339,6 +340,8 @@
     		#print 'var coauthors_moveUp_author_label = "' . __('+ Add author', 'co-authors') . '";';
     		#print 'var coauthors_moveDown_author_label = "' . __('+ Add author', 'co-authors') . '";';
     		#print 'var coauthors_delete_author_label = "' . __('+ Add author', 'co-authors') . '";';
    +		$coauthors_array = get_post_meta($post->ID, '_coauthor', false);
    +		print 'var coauthors_saved_authors = [' . (is_array($coauthors_array) ? implode(',', $coauthors_array) : '') . '];';
     		print '</script>';
    
     		//<script type='text/javascript' src='http://new-wineskins.org-beta/wp-includes/js/jquery/jquery.js?ver=1.1.4'></script>
    @@ -347,7 +350,7 @@
     		print '<script type="text/javascript" src="../' . PLUGINDIR . '/co-authors/admin.js"></script>';
     	//}
     }
    -add_action('admin_footer', 'coauthors_modify_post_sidebar'); //dbx_post_sidebar,edit_form_advanced
    +add_action('admin_footer-post.php', 'coauthors_modify_post_sidebar'); //dbx_post_sidebar,edit_form_advanced

    admin.js

    @@ -243,6 +243,14 @@
     		}
     	});
    
    +	//Fix by af to add in existing saved coauthors
    +	jQuery.each(coauthors_saved_authors, function(i, userID) {
    +		if (!addedAlready[userID]) {
    +			coauthors_add_coauthor(userID);
    +			addedAlready[userID] = true;
    +		}
    +	});
    +
     	//Remove coauthor post meta select option
     	//jQuery("#metakeyselect option[value='coauthor']").remove();
     	coauthors_check_first_delete_disabled_state();

    If anyone is interested, this bug exists because WordPress stopped printing "hidden" metadata fields (those beginning with underscores) in the "Custom Fields" box, which this plugin relied on to add the extra co-authors to the "Post Author" box. My fix simply prints this information elsewhere with the PHP then processes in accordingly in the JavaScript. Enjoy!

Topic Closed

This topic has been closed to new replies.

About this Plugin

About this Topic

Tags