# Pronouns Field for User Profiles

> Adds an optional "Pronouns" field to user profiles and a [wpide_pronouns] shortcode that shows them, for example next to an author's name.

- Type: PHP
- Runs: Run everywhere
- Category: [Users](https://wpide.com/library/category/users/)
- Tags: profile, fields, inclusive
- Author: WPIDE Team
- Installs: 0
- Updated: 2026-10-28
- Page: https://wpide.com/library/pronouns-profile-field/

## Code

```php
$wpide_pronouns_field = function ( $user ) {
    printf(
        '<h2>About you</h2><table class="form-table" role="presentation"><tr><th scope="row"><label for="wpide-pronouns">Pronouns</label></th><td><input type="text" id="wpide-pronouns" name="wpide_pronouns" value="%s" class="regular-text" maxlength="40" placeholder="e.g. she/her, they/them"></td></tr></table>',
        esc_attr( get_user_meta( $user->ID, 'wpide_pronouns', true ) )
    );
    wp_nonce_field( 'wpide_pronouns_' . $user->ID, 'wpide_pronouns_nonce' );
};
add_action( 'show_user_profile', $wpide_pronouns_field );
add_action( 'edit_user_profile', $wpide_pronouns_field );

$wpide_pronouns_save = function ( $user_id ) {
    if ( ! isset( $_POST['wpide_pronouns_nonce'] ) || ! wp_verify_nonce( sanitize_key( $_POST['wpide_pronouns_nonce'] ), 'wpide_pronouns_' . $user_id ) || ! current_user_can( 'edit_user', $user_id ) ) {
        return;
    }

    $value = isset( $_POST['wpide_pronouns'] ) ? substr( sanitize_text_field( wp_unslash( $_POST['wpide_pronouns'] ) ), 0, 40 ) : '';
    update_user_meta( $user_id, 'wpide_pronouns', $value );
};
add_action( 'personal_options_update', $wpide_pronouns_save );
add_action( 'edit_user_profile_update', $wpide_pronouns_save );

add_shortcode( 'wpide_pronouns', function ( $atts ) {
    $atts    = shortcode_atts( array( 'user' => 'current' ), $atts, 'wpide_pronouns' );
    $user_id = 'author' === $atts['user'] ? (int) get_post_field( 'post_author', get_the_ID() ) : get_current_user_id();
    $value   = $user_id ? get_user_meta( $user_id, 'wpide_pronouns', true ) : '';

    return $value ? '<span class="wpide-pronouns">(' . esc_html( $value ) . ')</span>' : '';
} );
```

## Notes

Use [wpide_pronouns user="author"] inside posts to show the post author's pronouns; the default shows the logged-in user's.

## How to use it

Install the free WPIDE plugin (https://wordpress.org/plugins/wpide/), find "Pronouns Field for User Profiles" in its snippet library and add it in one click; or create a new PHP snippet in WPIDE (or any code snippets plugin) and paste the code above. More snippets: https://wpide.com/library/
