Input data into a code: Change Wordpress user role after Woocommerce purchase
$10-30 USD
Në vazhdim
Postuar almost 8 years ago
$10-30 USD
Paguhet në dorëzim
***VERY SIMPLE JOB! SIMPLY INPUTTING DATA IN THE CODE***
I already have a code that works to change the user role when they make a purchase however I need it changed for my specific information and not sure how to do it.
I have a variable product with 6 variations and here is a list of which variation ID numbers and the role the user should be changed to:
Product Number 2212 & 2213 --> Change to role 'Silver Diamond'
Product Number 2210 & 2211 --> Change to role 'Gold Diamond'
Product Number 2208 & 2209 --> Change to role 'Platinum Diamond'
Every other product number --> Change to 'Customer'
HERE IS THE CODE:
/**
* Change Roles Upon Checkout
*
*/
function lgbk_add_member( $order_id ) {
$order = new WC_Order( $order_id );
$items = $order->get_items();
foreach ( $items as $item ) {
$product_name = $item['name'];
$product_id = $item['product_id'];
$product_variation_id = $item['variation_id'];
if ( $order->user_id > 0 && $product_id == '33' ) {
update_user_meta( $order->user_id, 'paying_customer', 1 );
$user = new WP_User( $order->user_id );
// Remove role
$user->remove_role( 'subscriber' );
// Add role
$user->add_role( 'contributor' );
}
}
}
add_action( 'woocommerce_order_status_completed', 'lgbk_add_member' );
give me chance
[login to view URL]
[login to view URL]
[login to view URL]
[login to view URL]
[login to view URL]
[login to view URL]
[login to view URL]
[login to view URL]
[login to view URL]
[login to view URL]
- [login to view URL]
[login to view URL]
[login to view URL]
[login to view URL]
[login to view URL]
[login to view URL] (in progress)
[login to view URL]
[login to view URL]
[login to view URL]
[login to view URL]
[login to view URL]
$20 USD në 0 ditë
4,8 (29 përshtypje)
4,4
4,4
6 freelancers are bidding on average $28 USD for this job
Hi employer. I am a professional developer in PHP, Wordpress, Laravel, CSS3, HTML5, Jquery. I think i can do this project. Please hire me. You will contentment with my skills if you hire me. Thanks