Here is the code:
function ur_update_role( $valid_form_data, $form_id, $user_id ) {
global $table_prefix;
$assign_roles_list = array();
if( isset( $valid_form_data['billing_ie']) && !empty( $valid_form_data['billing_ie']->value ) ) {
array_push( $assign_roles_list, 'ie' );
}
if ( ! empty( $assign_roles_list ) ) {
// Re-ordering roles according to priority.
$user_roles_list = ur_get_default_admin_roles();
foreach ( $user_roles_list as $key => $value ) {
if ( ! in_array( $key, $assign_roles_list, true ) ) {
unset( $user_roles_list[ $key ] );
} else {
$user_roles_list[ $key ] = true;
}
}
$field_name = $table_prefix . 'capabilities';
update_user_meta( $user_id, $field_name, $user_roles_list );
}
}
Related Posts:
- Which hook should I use to capture $_POST(‘password’) via profile update and password reset
- Adding an action within a function that is being called by add_filter
- Remove action on product archive page [closed]
- In WooCommerce filter the available Payment Methods by User Role [closed]
- How to remove_action inside class [duplicate]
- Username field is not shown in Woocommerce’s registration contact form
- Unable to programmatically remove product from WooCommerce cart
- Custom Redirect after registration in WooCommerce
- Is there a Woocommerce hook that fires when applying a coupon but before checking if it’s valid?
- What is the action hook for an order that fails on frontend checkout in WooCommerce?
- Remove action added through function
- How can I add an additional action button into the woocommerce admin order page?
- Edit WooCommerce product content based on category
- Admin access for custom user capabilities
- WP_Query with meta_query for children
- WooCommerce limited role
- Force User Registration before visitng Checkout Page
- Register a new user on wooCommerce using Rest API
- Allow WooCommerce existing customers to checkout without being logged in [closed]
- How to list all WC products by their attributes values?
- Auto generate user email while registration
- Tried to create a user role that can only edit user information, but my test account cannot view the dashboard. What am I missing?
- WooCommerce Hook: Content get’s displayed twice and not AFTER the order total
- woocommerce_new_product action doesn’t fire
- Woocommerce check if email already created order recently [closed]
- WooCommerce which roles and capabilities control user login re-direct to Woo Account Page?
- WooCommerce Registration redirect based on page ID
- password_reset doesnt work
- Woocommerce – Adding row to cart table
- Block Disposable Emails on Woocommerce Registration
- Clients with empty username are not receiving request new password email
- WooCommerce Admin order – Only run action if user is loaded
- Functions.php change for Woocommerce not working
- WooCommerce get_author_posts_url() – Author URL redirecting to shop base
- Woocommerce Register Error
- Display custom product option in admin order details
- I have 3 types of prices in WP and I need to change price for each specific user role using hooks
- Make e-Mail optional on Woocommerce sign up
- Switch to user link shortcode
- How to show specific admin menu to specific user role?
- Need help with woocommerce roles
- Combine one action and one filter
- Impossible to create a new WooCommerce customer using Rest API
- How can I send information when a order is completed to my own POS?
- Registration roles
- Parameters in woocommerce_before_add_to_cart_button hook
- How to send Woocommerce Customer Details (Name, Email and Phone Number) to Admin upon signup
- How to change lost password email text using custom plugin wordpress?
- Overriding Plugin function in your child theme
- How to change user role after login?
- How can I locate where the actions are defined? [duplicate]
- add_action don’t updates theme layout when using values from the WordPress customizer
- Woocommerce add a text field if specific option is selected
- Woocommerce customer role doesn’t change if user is already a subscriber [closed]
- Redirect After Registration on Specific Link
- add_filter not works in ajax
- Custom Registration Fields woocommerce
- How Do I Access Parameters Emitted by an Action?
- Changing second user role while updating/downgrading membership level – s2member [closed]
- How to add a menu page for options in wordpress for user that has the role of vendor?
- How to disable the “Upgrade or Downgrade” button in “My account” of WooCommerce Subscriptions
- Restrict the shop_manager role to the WooCommerce Orders Page
- Change WooCommerce registration form/way?
- DatePicker in Woocommerce (My Account) Registration [closed]
- Can I remove WooCommerce specific product categories from shop managers?
- Remove login fields from /customer-account page [closed]
- Reposition variation stock message
- Pass custom Checkout field value to Stripe gateway in WooCommerce
- Woocommerce checkout via external page [closed]
- Woocommerce reviews xss issue [closed]
- How to select default Woocommerce category page
- Creating Product Table using Gutenberg
- I can ‘t display product images based on the label
- SKU for each product on every page
- Woocommerce get billing state manually
- WooCommerce slider filter for numerical attributes
- Unable to paste google analytics con header.php [closed]
- WooCommerce Subscriptions: Hide one variation subscription
- Contact form 7 send product PDF after submit
- Add sub variations in product page
- Woo commerce product quantity wise SKU
- Override une fonction dans une class Woocommerce
- List of JS events in the WooCommerce frontend
- Redirecting orders by company field
- Woocommerce shop page not showing all products
- Wrong Billing Information in WC_Checkout->get_checkout_fields(‘billing’)?
- How to display two different custom taxonomy terms on a WooCommerce single product page
- how can my customers view their purchased products history like an invoice in a specific page on WordPress
- How to customize product at cart page
- WooCommerce Storefront site-header padding
- How to check which shortcode is using my template?
- How to get woocommerce integration instance?
- Create woocommerce order on new user registration
- Redirect whole website or pages to /wp-admin in wordpress
- Storefront Child Theme show product attribute [closed]
- Send data to external websites when there is an update or create a post
- WooCommerce product permalink based on product’s current category
- Disable duplicate WC product category URLs
- how should i get products based on tags in woocommerce
- Add custom text to product category page