In Progress

Input data into a code: Change Wordpress user role after Woocommerce purchase

***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' );

Skills: HTML, PHP, Plugin, WooCommerce, WordPress

See more:

About the Employer:
( 59 reviews ) Sheridan, United States

Project ID: #10415264

Awarded to:

shaumyasinha1002

give me chance [url removed, login to view] [url removed, login to view] [url removed, login to view] [url removed, login to view] [url removed, login to view] [url removed, login to view] [url removed, login to view] http: More

$20 USD in 0 days
(4 Reviews)
1.8

7 freelancers are bidding on average $26 for this job

MyBB

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

$35 USD in 1 day
(38 Reviews)
5.3
yogeshssanwal

Hi there - My name is Yogesh. I’ve read your [url removed, login to view] team has 4 years experience designing and developing mobile apps and Websites.I would approach your project by starting with wireframes and getting the site complet More

$25 USD in 1 day
(57 Reviews)
5.1
shahin2014

Hi, I'm working freelancer and theme forest for three [url removed, login to view] is my mission and vision.I can start your project right now. I have huge knowledge on wordpress theme development from scratch.I can make psd to h More

$61 USD in 1 day
(20 Reviews)
4.5
webcast

Hello sir/mam, I am good at : 1. WordPress web development 2. PSD to HTML 3. Responsive web development 4. Graphics Designing 5. Photoshop 6. PHP 7. html + CSS Styling 8. js & jQuery. you can check my More

$35 USD in 1 day
(17 Reviews)
4.2
huwngtc

Hi, I'm Hung from Vietnam. Here is my personal website [url removed, login to view] You can see all my relevant experiences and qualifications there. Please leave me a message then we can discuss about this job. More

$25 USD in 1 day
(10 Reviews)
4.1
sumonkhansl

Hi i see your requirements. and code also. i can start working from now and think complete within 1 hours. Thank you sumon

$25 USD in 0 days
(18 Reviews)
4.1
langlangFan

As you see my skill, wordpress and web site development are my specialty. This is my first proposal on freelancer but if you hire me, I'll propose more cheaper or even free. If you believe me, you'll get crazy succ More

$15 USD in 1 day
(3 Reviews)
2.4
letsmeetranjit

Hi I am Ranjit. I have 4 years experiences in Wordpress and and i have a good knowledge about the bootstrap 3.0 and responsive. My experience provides development process smoothly, fast and with high quality thus More

$25 USD in 1 day
(0 Reviews)
0.0