• Resolved pablostradingco

    (@pablostradingco)


    I accidentally deleted the woocommerce ‘customer’ user role with the “User Role Editor” plugin. Is it possible to regenerate the role somehow? I know I can create it again with the plugin but can’t seem to find a list of capabilities in the documentation.

Viewing 4 replies - 1 through 4 (of 4 total)
  • Mohit Mishra

    (@mohitmishra)

    Hello @pablostradingco You can use the below code to create customer role again, paste the below code in the theme’s functions.php

    /**
    * This function is used to create another user role
    * 
    * @name create_customer_user_role
    * @since 1.0.0
    * @author Mohit Mishra
    * @link https://makewebbetter.com 
    */
    function create_customer_user_role() {
    	$mwb_create_user_role = get_option( 'created_customer_user_role' , false );
    	if ( empty( $mwb_create_user_role ) ) {
    		// Customer role.
    		add_role(
    			'customer',
    			'Customer',
    			array(
    				'read' => true,
    				)
    			);
    		update_option( 'created_customer_user_role' , true );
    	}
    }
    add_action( 'wp_loaded', 'create_customer_user_role' );

    @mohitmishra

    Hi, I deleted both Customer AND Shop Manager user roles by mistake – I have used your awesome code from this post to restore the Customer role and it worked perfectly! ??

    I now desperately need to restore the Shop Manager role as well – could you please provide me the correct code with default WooCommerce Shop Manager capabilities included?

    Any help would be really appreciated.

    Many thanks

    Plugin Support EtienneP a11n

    (@etiennep)

    Hi all!

    User Role Editor has a guide here on how to restore deleted roles – https://www.role-editor.com/how-to-restore-deleted-wordpress-user-roles/

    In short, just deactivating and reactivating WooCommerce will restore the user roles from WooCommerce that was removed

    Plugin Support EtienneP a11n

    (@etiennep)

    We haven’t heard back from you in a while, so I’m going to mark this as resolved – if you have any further questions, you can start a new thread.

Viewing 4 replies - 1 through 4 (of 4 total)
  • The topic ‘Restore Default User Roles’ is closed to new replies.