Just use $user->set_role( 'learner_member' ); instead of both lines where you are removing and adding the role.
Related Posts:
- In WooCommerce filter the available Payment Methods by User Role [closed]
- Admin access for custom user capabilities
- WP_Query with meta_query for children
- WooCommerce limited role
- 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 which roles and capabilities control user login re-direct to Woo Account Page?
- WooCommerce Admin order – Only run action if user is loaded
- WooCommerce get_author_posts_url() – Author URL redirecting to shop base
- I have 3 types of prices in WP and I need to change price for each specific user role using hooks
- Switch to user link shortcode
- How to show specific admin menu to specific user role?
- Assign user role by text field in WordPress (Woocommerce) [closed]
- Need help with woocommerce roles
- How to change user role after login?
- Woocommerce customer role doesn’t change if user is already a subscriber [closed]
- 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
- Can I remove WooCommerce specific product categories from shop managers?
- Add another user role based on a defined input field in WordPress (Woocommerce)
- Order by rating not works in wp_query
- WooCommerce: Add New Report Tab
- Woocommerce checkout fields on the same line
- How to add multiple product gallery images from front-end
- Hide income in Woocomercer [closed]
- How do you add custom metadata to WooCommerce orders? Specifically a second external order ID
- Hide tabs on woocommerce product editor for user role
- Woocommerce add_to_cart non-register visitor not working
- WooCommerce: The model of e-mail is displaying only the html, not css [closed]
- How to show loading spinner after click on add to cart button [closed]
- Authenticate user into wordpress via 3rd party system, both with the same domain
- Arranging Product Details on Shop Page
- How to get woocommerce subscription next payment date or date when subscription expires in woocommerce_subscription_renewal_payment_complete hook?
- Display Message if woocommerce coupon is not applicable to some items in the cart
- (Woocommerce) How to add a custom page between cart and checkout with a file upload field per product item in the cart?
- Force uppercase on some WooCommerce checkout fields input
- Display custom field without plugin in woocommerce
- How to output php between header and woocommerce container
- WooCommerce – How can I make single product gallery show two images on the slider at once?
- How to delete all customer user account that haven’t placed a single order?
- How do I hide ‘out of stock’ products in the admin ‘product’ page?
- Hide the prefix before the price of the product [closed]
- Backend users list – add Woocommerce meta to table
- Show add to cart button and quantity field when no price is entered [closed]
- How to get woocommerce product collection in template file
- Results not being printed
- Remove ‘product’ & ‘product-cateogory’ from url – woocommerce [closed]
- Is there a hook in woocommerce for when a payment fails to display a custom error message?
- How to show notice alert only on product dashboard page?
- Retrieving Tag Name in Template Part from Filtered URL
- ajax request in wordpress
- Woocommerce product rewrite rules not working
- How to display a table below each product in product list/loop
- how to remove this image? [closed]
- WooCommerce apply shipping rates based on price
- Extra items added to cart on refresh, woocommerce
- How disable some product features on woocomerce?
- WooCommerce – Split Multiple Items into Individual Line Items
- Change “Select Options” label in button to “Buy Now!” in store page
- Woocommerce: Any way to list all products *without* a specific attribute?
- Woocommerce product import exports product with price rounded to integer? [closed]
- Filter by Price filter button not working
- porto theme pagination on woocommerce not working
- Adding preference buttons to main nav that persist via user sessions. (Woocommerce)
- Woocommerce custom log in and register
- Is doing a database query in Woocommerce efficient to only display posts from a certain category?
- Call product search from custom hook
- CallBack URL for payment gateway redirecting to homepage instead of executing callback function
- Display when items are in Woocommerce cart but hide when empty
- Printing product variation return array to string conversion error
- woocommerce deposit Form with AJAX and shortcode won’t update but add to previous output
- How to get cookie value?
- Woocommerce Disabling Auto Restocking for Cancelled Orders
- Custom pagination permalink structure Product page
- Woocommerce modifying the html on the checkout page?
- Pseudo class :before don’t working in a specific button
- How to speed up “My Account > Orders Page” on Site with More than 200,000 orders?
- Editing product categories suddenly crashes website and goes back to wordpress installation
- ACF in WooCommerce mail template
- WooCommerce product id as permalink
- Merge “description” and “additional informations” product tab
- I need to refresh the checkout page if someone changes the zip code
- Get user active posts randomly
- add_filter not works in ajax
- Website Tablet Check Out Field Issue
- WooCommerce order created via REST – sending the date_created along
- Get Third Level Categories WooCommerce
- Change wp-login.php? Problem with .htaccess password protection and multi user shop
- Show pop up message for specific categoryies
- How to remove content from hacked pages? [closed]
- Disable WooCommerce Address State Dropdown
- How to show detailed order history on woocommerce product page [closed]
- Fetch products with filter by similar categories at same time
- Trying query woocommerce product order by menu order and stock status
- editing product page template – getting template for related products not working
- Disable Woocommerce Block Editor
- Woocommerce backend sorting product drag drop by menu_order to date
- Save customer email via WPForms on checkbox marking when placing the Woocommerce order
- How to detect changes in WooCommerce store (react)?