Support » Plugin: Co-Authors Plus » add_coauthors() method: user_login vs user_nicename

  • Hey there,

    Thanks for the excellent plugin. I just have a small problem with it. In the add_coauthors() method in the main plugin file, you “pluck” existing coauthors’ user_login on line 769:

    $existing_coauthors = wp_list_pluck( get_coauthors( $post_id ), 'user_login' );
    and add the current user’s user_login on line 776:

    $coauthors = array( $current_user->user_login );

    , but when comes time to build the coauthors User objects, on line 784, you use ‘user_nicename’:

    $author = $this->get_coauthor_by( 'user_nicename', $author_name );

    In almost all WordPress installs, user_nicename and user_login are identical. It just so happens that they’re not in mine. Therefore coauthors are not added. Is there a particular reason why ‘user_login’ isn’t used everywhere?

    Thanks in advance!

Viewing 1 replies (of 1 total)
  • OK I’ve had the time to delve a bit more into the code and it seems that user_login and user_nicename are used as if they were interchangeable. That is _not_ the case. They’re not filtered the same way on user creation. For example, spaces and the @ character are OK in user_login and not OK in user_nicename, which is meant to be used as a URL slug.

    Anybody else ever run into this issue?

Viewing 1 replies (of 1 total)
  • The topic ‘add_coauthors() method: user_login vs user_nicename’ is closed to new replies.