Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP

Loading…

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

Merged
merged 2 commits into from

2 participants

@STRML

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.

@danielbachhuber

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.

@danielbachhuber danielbachhuber merged commit dfcfab0 into from
@danielbachhuber

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.

@STRML

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
Commits on Nov 29, 2012
  1. @STRML

    Pull 67 (Automattic#67) was incomplete. Contains wp-admin fixes to co…

    STRML authored
    …mplete the move to user_nicename.
Commits on Dec 4, 2012
  1. @STRML
This page is out of date. Refresh to see the latest.
Showing with 8 additions and 4 deletions.
  1. +3 −2 co-authors-plus.php
  2. +5 −2 js/co-authors-plus.js
View
5 co-authors-plus.php
@@ -333,6 +333,7 @@ function coauthors_meta_box( $post ) {
<input type="text" name="coauthorsinput[]" readonly="readonly" value="<?php echo esc_attr( $coauthor->display_name ); ?>" />
<input type="text" name="coauthors[]" value="<?php echo esc_attr( $coauthor->user_login ); ?>" />
<input type="text" name="coauthorsemails[]" value="<?php echo esc_attr( $coauthor->user_email ); ?>" />
+ <input type="text" name="coauthorsnicenames[]" value="<?php echo esc_attr( $coauthor->user_nicename ); ?>" />
</span>
</li>
<?php
@@ -697,7 +698,7 @@ function add_coauthors( $post_id, $coauthors, $append = false ) {
// Add each co-author to the post meta
foreach( array_unique( $coauthors ) as $key => $author_name ){
- $author = $this->get_coauthor_by( 'user_login', $author_name );
+ $author = $this->get_coauthor_by( 'user_nicename', $author_name );
$term = $this->update_author_term( $author );
$coauthors[$key] = $term->slug;
}
@@ -844,7 +845,7 @@ function ajax_suggest() {
$authors = $this->search_authors( $search, $ignore );
foreach( $authors as $author ) {
- echo $author->ID ." | ". $author->user_login ." | ". $author->display_name ." | ". $author->user_email ."\n";
+ echo $author->ID ." | ". $author->user_login ." | ". $author->display_name ." | ". $author->user_email ." | ". $author->user_nicename . "\n";
}
die();
View
7 js/co-authors-plus.js
@@ -52,7 +52,7 @@ jQuery(document).ready(function () {
;
// Update the value of the hidden input
- co.siblings('input[name="coauthors[]"]').val(author.login);
+ co.siblings('input[name="coauthors[]"]').val(author.nicename);
}
@@ -215,6 +215,7 @@ jQuery(document).ready(function () {
author.login = jQuery.trim(vals[1]);
author.name = jQuery.trim(vals[2]);
author.email = jQuery.trim(vals[3]);
+ author.nicename = jQuery.trim(vals[4]);
if(author.id=="New") {
//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 () {
'type': 'hidden',
'id': 'coauthors_hidden_input',
'name': 'coauthors[]',
- 'value': unescape(author.login)
+ 'value': unescape(author.nicename)
})
;
@@ -392,6 +393,7 @@ jQuery(document).ready(function () {
var $post_coauthor_logins = jQuery('input[name="coauthors[]"]');
var $post_coauthor_names = jQuery('input[name="coauthorsinput[]"]');
var $post_coauthor_emails = jQuery('input[name="coauthorsemails[]"]');
+ var $post_coauthor_nicenames = jQuery('input[name="coauthorsnicenames[]"]');
post_coauthors = [];
@@ -400,6 +402,7 @@ jQuery(document).ready(function () {
login: $post_coauthor_logins[i].value,
name: $post_coauthor_names[i].value,
email: $post_coauthor_emails[i].value,
+ nicename: $post_coauthor_nicenames[i].value
});
}
Something went wrong with that request. Please try again.