# Adding extra user profile fields in WordPress

> Add extra fields such as social media links to WordPress user profiles using PHP filters in your theme.

Source: https://helpcenter.ruachost.com/wordpress/guides/adding-additional-user-profile-fields-in-wordpress/

By default, WordPress user profiles include basic fields such as name, email, and website. If you want to collect more information (e.g., social media links, phone numbers, or company details), you can add **custom user profile fields**. On **ruachost.com**, this can be done using PHP filters.

## Why Add Extra Fields?

- Enhance user profiles with richer information.
- Allow authors to link social media accounts.
- Support membership or community sites with custom data.
- Provide additional metadata for plugins or themes.

## Steps to Add Custom Fields

1. **Log in to WordPress** with an administrator account.
2. In the dashboard, go to **Appearance → Theme Editor**.
3. Select your active theme and open the **functions.php** file.
4. Add the following code snippet:

   ```
   // Add Twitter and Facebook fields to user profiles
   function add_new_contactmethods($contactmethods) {
       // Add Twitter field
       $contactmethods['twitter'] = 'Twitter';
       // Add Facebook field
       $contactmethods['facebook'] = 'Facebook';
       return $contactmethods;
   }
   add_filter('user_contactmethods', 'add_new_contactmethods', 10, 1);
   ```
5. Click **Update File** to save changes.
6. Go to **Users → Profile** → You’ll now see new fields for **Twitter** and **Facebook**.

## ⚙️ Example: Adding Custom Fields for Business Sites

You can extend this to include more fields:

```
function add_custom_contactmethods($contactmethods) {
    $contactmethods['linkedin'] = 'LinkedIn Profile';
    $contactmethods['phone'] = 'Phone Number';
    $contactmethods['company'] = 'Company Name';
    return $contactmethods;
}
add_filter('user_contactmethods', 'add_custom_contactmethods', 10, 1);
```

## Important Notes

- Always back up your theme files before editing.
- Use a **child theme** to preserve changes during updates.
- Custom fields are stored as user metadata and can be retrieved with `get_user_meta()`.
- Avoid adding sensitive fields unless you have proper security measures in place.
