Use user nicename, not user login

Open Beginner friendly
#1,310 7 comments 0 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

Assessment

Difficulty
2/5
Estimated time
1-3 hours
Newbie friendliness
72/100
Issue type
Bug
Clarity
Clearly specified
Activity status
Quiet
Tech stack
php, wordpress
Domain
api, backend

Research direction

Start with includes/model/class-user.php and its get_preferred_username() method, then read includes/class-signature.php and get_signature_options_key_for(). Verify how ActivityPub currently derives the username and signature key from WordPress user data. Done means the ActivityPub username uses user_nicename consistently and the related unnecessary sanitization is no longer needed.

Written by the indexing model from the issue text.

Description

[Pri] Normal Needs triage
Quick summary

User nicename is a unique, sanitized version of user login. Since user login can be an email address and contain spaces or special characters, user nicename is used for creating permalinks etc. throughout the rest of WordPress. Therefore, it should be used as the ActivityPub user name string, rather than user login.

https://wordpress.stackexchange.com/questions/127905/user-login-vs-user-nicename

includes/model/class-user.php:

public function get_preferred_username() {
  return \get_the_author_meta( 'nicename', $this->_id );
}

In fact there is some sanitization happening in includes/class-signature.php that shouldn't be necessary if using the nicename:

protected static function get_signature_options_key_for( $user_id ) {
  $id = $user_id;

  if ( $user_id > 0 ) {
    $user = \get_userdata( $user_id );
    // No need to sanitize nicename
    $id = $user->user_nicename;
  }

  return 'activitypub_keypair_for_' . $id;
}

Similar to #141, but doesn't require complete user customization of ActivityPub user name.

Steps to reproduce

Install ActivityPub and see that it is using user_login, not user_nicename.

Site owner impact

More than 60% of the total website/platform users

Severity

Minor

What other impact(s) does this issue have?

No response

If a workaround is available, please outline it here.

No response

Dominant language
PHP
Stars
582
Forks
93
Avg merge
20h 46m
Merged PRs (30d)
100

Contributor guide

Open the contributing guide

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

More from Automattic/wordpress-activitypub

All issues in Automattic/wordpress-activitypub

Similar issues

More PHP issues

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.