Tweak some functions.php code to change wordpress user roles after purchase
$10-30 USD
Zaprt
Objavljeno pred približno 8 leti
$10-30 USD
Plačilo ob dostavi
I need user roles to be change after they purchase a package level.
For example, if they purchase a Silver Diamond Package, I need their user role to be changed to "Silver Diamond"
I need the code below modified with my specific product info in. There will be 4 different levels that someone can be changed to when they purchase a product.
I only wish to pay $10 since this is so simple. This is a good project for a person to use to increase their Freelancer cred.
Here is the code we have so far:
/**
* 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' );
Hello!
With 98% to 99% completion rate, 900+ successfully completed projects, and a 4.99 reputation (maximum possible, 5.0) (can be verified on my profile page https://www.freelancer.com/u/rajeshsonisl.html !!)... you can never go wrong choosing me :)
I am available to get started on your project right away. I look forward to your reply.
Thanks.
Kind Regards,
Rajesh Soni
Hello. Wordpress dev expert ready to help you with role code development. I have more 200 good reviews in dev projects, so all will be done on highest level.
Price can be discussed.
Please, do not award project until we will clear details.
Hi there - My name is Jhalak. I’ve read your brief and can see that you’d like to build an Website. My 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 completed, before starting the actual development phase. I am highly qualified for this project and would love to speak with you further about taking this project on. If you'd like to view my previous work, take a look at my Freelancer Portfolio.
Regards,
Jhalak
Thanks, Diamond looking forward for your reply.
Hi, I've over-viewed the details of the project provided by you and I am please to declare myself the right candidate for this project as I've completed many successful projects of such kind (urls will be provided on request). If you are looking for quality results in reasonable time and rate then lets discuss the further details for successful completion of project.
We deliver on time and on budget.
I can start on it right now.
I can start on it right now.
Hi
I am highly interested to do this project. I will make you happy.I don’t need any upfront or milestone payment. Pay me when you will happy. Looking forward. Thanks