Automattic / Automattic/wordpress-activitypub

Use user nicename, not user login

Open
#1,310 7 comments 0 reactions 0 assignees View on GitHub
[Pri] Normal Needs triage
Dominant language
PHP
Stars
579
Forks
92
Avg merge
13h 5m
Merged PRs (30d)
85

Description

### 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`:
```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:
```php
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_

Contributor guide

Open the contributing guide

Assessment

This issue has not been assessed yet.

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.