# "How Did You Hear About Us?" on Registration

> Asks new members how they found your site when they register and shows the answer in a column on the Users screen.

- Type: PHP
- Runs: Run everywhere
- Category: [Users](https://wpide.com/library/category/users/)
- Tags: registration, marketing, users
- Author: WPIDE Team
- Installs: 0
- Updated: 2026-10-28
- Page: https://wpide.com/library/registration-referral-source/

## Code

```php
// Value => label.
$wpide_referral_options = array(
    'search'  => 'Search engine',
    'social'  => 'Social media',
    'friend'  => 'A friend or colleague',
    'podcast' => 'Podcast or video',
    'other'   => 'Somewhere else',
);

add_action( 'register_form', function () use ( $wpide_referral_options ) {
    echo '<p><label for="wpide_referral">How did you hear about us?</label><select name="wpide_referral" id="wpide_referral" class="input"><option value="">Choose one (optional)</option>';

    foreach ( $wpide_referral_options as $value => $label ) {
        printf( '<option value="%1$s">%2$s</option>', esc_attr( $value ), esc_html( $label ) );
    }

    echo '</select></p>';
} );

add_action( 'register_new_user', function ( $user_id ) use ( $wpide_referral_options ) {
    $value = isset( $_POST['wpide_referral'] ) ? sanitize_key( $_POST['wpide_referral'] ) : '';

    if ( isset( $wpide_referral_options[ $value ] ) ) {
        update_user_meta( $user_id, 'wpide_referral', $value );
    }
} );

add_filter( 'manage_users_columns', function ( $columns ) {
    $columns['wpide_referral'] = 'Found us via';

    return $columns;
} );

add_filter( 'manage_users_custom_column', function ( $output, $column, $user_id ) use ( $wpide_referral_options ) {
    if ( 'wpide_referral' === $column ) {
        $value  = get_user_meta( $user_id, 'wpide_referral', true );
        $output = isset( $wpide_referral_options[ $value ] ) ? esc_html( $wpide_referral_options[ $value ] ) : '&mdash;';
    }

    return $output;
}, 10, 3 );
```

## Notes

Edit $wpide_referral_options to change the choices; answers are stored in the wpide_referral user meta.

## How to use it

Install the free WPIDE plugin (https://wordpress.org/plugins/wpide/), find ""How Did You Hear About Us?" on Registration" 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/
