Title: Create a Role Programmatically
Last modified: August 27, 2021

---

# Create a Role Programmatically

 *  Resolved [ermWP](https://wordpress.org/support/users/ermwp/)
 * (@ermwp)
 * [4 years, 8 months ago](https://wordpress.org/support/topic/create-a-role-programmatically/)
 * I would like to create a UM role via code if it does not already exist on the
   site when I install a custom plugin. How can I create a UM role via code?

Viewing 4 replies - 1 through 4 (of 4 total)

 *  Plugin Contributor [Champ Camba](https://wordpress.org/support/users/champsupertramp/)
 * (@champsupertramp)
 * [4 years, 8 months ago](https://wordpress.org/support/topic/create-a-role-programmatically/#post-14817495)
 * Hi [@ermwp](https://wordpress.org/support/users/ermwp/)
 * You can check this wp.org doc to create a new role:
    [https://developer.wordpress.org/reference/functions/add_role/](https://developer.wordpress.org/reference/functions/add_role/)
 * Regards,
 *  Thread Starter [ermWP](https://wordpress.org/support/users/ermwp/)
 * (@ermwp)
 * [4 years, 8 months ago](https://wordpress.org/support/topic/create-a-role-programmatically/#post-14828600)
 * Thank you for the reply. Will that make it a UM custom role? I know how to make
   a WP role. How do I programmatically make a custom UM role?
 *  Plugin Contributor [Champ Camba](https://wordpress.org/support/users/champsupertramp/)
 * (@champsupertramp)
 * [4 years, 8 months ago](https://wordpress.org/support/topic/create-a-role-programmatically/#post-14830443)
 * Hi [@ermwp](https://wordpress.org/support/users/ermwp/)
 * When you create a role with `add_role` it should create the UM Role. Try running
   this code: `add_role( "um_test_role","UM Test Role", array() );`
 * Once the role is added, go to WP Admin > Ultimate Member > User Roles > see “
   UM Test Role”.
 * Regards,
 *  Plugin Contributor [Champ Camba](https://wordpress.org/support/users/champsupertramp/)
 * (@champsupertramp)
 * [4 years, 8 months ago](https://wordpress.org/support/topic/create-a-role-programmatically/#post-14849477)
 * Hey there!
 *  This thread has been inactive for a while so we’re going to go ahead and mark
   it Resolved.
 * Please feel free to re-open this thread by changing the Topic Status to ‘Not 
   Resolved’ if any other questions come up and we’d be happy to help. 🙂
 * Regards,

Viewing 4 replies - 1 through 4 (of 4 total)

The topic ‘Create a Role Programmatically’ is closed to new replies.

 * ![](https://ps.w.org/ultimate-member/assets/icon-256x256.png?rev=3160947)
 * [Ultimate Member – User Profile, Registration, Login, Member Directory, Content Restriction & Membership Plugin](https://wordpress.org/plugins/ultimate-member/)
 * [Frequently Asked Questions](https://wordpress.org/plugins/ultimate-member/#faq)
 * [Support Threads](https://wordpress.org/support/plugin/ultimate-member/)
 * [Active Topics](https://wordpress.org/support/plugin/ultimate-member/active/)
 * [Unresolved Topics](https://wordpress.org/support/plugin/ultimate-member/unresolved/)
 * [Reviews](https://wordpress.org/support/plugin/ultimate-member/reviews/)

## Tags

 * [code](https://wordpress.org/support/topic-tag/code/)
 * [manually](https://wordpress.org/support/topic-tag/manually/)
 * [role](https://wordpress.org/support/topic-tag/role/)

 * 4 replies
 * 2 participants
 * Last reply from: [Champ Camba](https://wordpress.org/support/users/champsupertramp/)
 * Last activity: [4 years, 8 months ago](https://wordpress.org/support/topic/create-a-role-programmatically/#post-14849477)
 * Status: resolved