Skip to content
This repository

Fix for pull 67: Map author slugs to user_nicename #90

Merged
merged 2 commits into from over 1 year ago

2 participants

Samuel Reed Daniel Bachhuber
Samuel Reed

Pull 67 was incomplete. Contains wp-admin fixes to complete the move to user_nicename.

Essentially, the hidden field in the wp-admin post edit screen passes user_login to the backend, which then attempts to look up a user by user_nicename. This works in most cases except when users have an email address as a login name, which converts to a url safe user_nicename (e.g. "mail@example.com" -> "mailexample-com").

This pull fixes this issue by exporting user_nicename to the template and passing it via javascript to the hidden field.

Daniel Bachhuber
Collaborator

Sorry, I didn't have a chance to look at this yet :( I'm headed offline for a few days but it's at the top of my list for when I get back.

Daniel Bachhuber danielbachhuber merged commit dfcfab0 into from
Daniel Bachhuber
Collaborator

Thanks much. This is now live on WordPress.com and I hope to release the improvement with the plugin at the end of next week.

Samuel Reed

Glad it made it through - when 3.0.4 comes out I can finally update my sites. I appreciate the attention to the issue.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Showing 2 unique commits by 1 author.

Nov 29, 2012
Samuel Reed STRML Pull 67 (Automattic#67) was incomplete. Contains wp-admin fixes to co…
…mplete the move to user_nicename.
ec2f594
Dec 04, 2012
Samuel Reed STRML Updated add_coauthors to use user_nicename. 91416fb
This page is out of date. Refresh to see the latest.

Showing 2 changed files with 8 additions and 4 deletions. Show diff stats Hide diff stats

  1. +3 2 co-authors-plus.php
  2. +5 2 js/co-authors-plus.js
5 co-authors-plus.php
@@ -333,6 +333,7 @@ function coauthors_meta_box( $post ) {
333 333 <input type="text" name="coauthorsinput[]" readonly="readonly" value="<?php echo esc_attr( $coauthor->display_name ); ?>" />
334 334 <input type="text" name="coauthors[]" value="<?php echo esc_attr( $coauthor->user_login ); ?>" />
335 335 <input type="text" name="coauthorsemails[]" value="<?php echo esc_attr( $coauthor->user_email ); ?>" />
  336 + <input type="text" name="coauthorsnicenames[]" value="<?php echo esc_attr( $coauthor->user_nicename ); ?>" />
336 337 </span>
337 338 </li>
338 339 <?php
@@ -697,7 +698,7 @@ function add_coauthors( $post_id, $coauthors, $append = false ) {
697 698 // Add each co-author to the post meta
698 699 foreach( array_unique( $coauthors ) as $key => $author_name ){
699 700
700   - $author = $this->get_coauthor_by( 'user_login', $author_name );
  701 + $author = $this->get_coauthor_by( 'user_nicename', $author_name );
701 702 $term = $this->update_author_term( $author );
702 703 $coauthors[$key] = $term->slug;
703 704 }
@@ -844,7 +845,7 @@ function ajax_suggest() {
844 845 $authors = $this->search_authors( $search, $ignore );
845 846
846 847 foreach( $authors as $author ) {
847   - echo $author->ID ." | ". $author->user_login ." | ". $author->display_name ." | ". $author->user_email ."\n";
  848 + echo $author->ID ." | ". $author->user_login ." | ". $author->display_name ." | ". $author->user_email ." | ". $author->user_nicename . "\n";
848 849 }
849 850
850 851 die();
7 js/co-authors-plus.js
@@ -52,7 +52,7 @@ jQuery(document).ready(function () {
52 52 ;
53 53
54 54 // Update the value of the hidden input
55   - co.siblings('input[name="coauthors[]"]').val(author.login);
  55 + co.siblings('input[name="coauthors[]"]').val(author.nicename);
56 56 }
57 57
58 58
@@ -215,6 +215,7 @@ jQuery(document).ready(function () {
215 215 author.login = jQuery.trim(vals[1]);
216 216 author.name = jQuery.trim(vals[2]);
217 217 author.email = jQuery.trim(vals[3]);
  218 + author.nicename = jQuery.trim(vals[4]);
218 219
219 220 if(author.id=="New") {
220 221 //alert('Eventually, this will allow you to add a new author right from here. But it\'s not ready yet. *sigh*');
@@ -304,7 +305,7 @@ jQuery(document).ready(function () {
304 305 'type': 'hidden',
305 306 'id': 'coauthors_hidden_input',
306 307 'name': 'coauthors[]',
307   - 'value': unescape(author.login)
  308 + 'value': unescape(author.nicename)
308 309 })
309 310 ;
310 311
@@ -392,6 +393,7 @@ jQuery(document).ready(function () {
392 393 var $post_coauthor_logins = jQuery('input[name="coauthors[]"]');
393 394 var $post_coauthor_names = jQuery('input[name="coauthorsinput[]"]');
394 395 var $post_coauthor_emails = jQuery('input[name="coauthorsemails[]"]');
  396 + var $post_coauthor_nicenames = jQuery('input[name="coauthorsnicenames[]"]');
395 397
396 398 post_coauthors = [];
397 399
@@ -400,6 +402,7 @@ jQuery(document).ready(function () {
400 402 login: $post_coauthor_logins[i].value,
401 403 name: $post_coauthor_names[i].value,
402 404 email: $post_coauthor_emails[i].value,
  405 + nicename: $post_coauthor_nicenames[i].value
403 406 });
404 407 }
405 408

Tip: You can add notes to lines in a file. Hover to the left of a line to make a note

Something went wrong with that request. Please try again.