B
B
Boris Shpakovsky2016-04-28 16:28:55
WordPress
Boris Shpakovsky, 2016-04-28 16:28:55

Guys, I need a plugin to sell video courses on wordpress, am I thinking right?

I see all kinds of plugins related to membership (membership), but I would like individual video courses to be sold as different products. This is how I understand the system: you need to make a post in which course videos will be gradually added, as they appear, this post will be closed until a person pays for access to it. In the same way, new posts with courses are created. It's just that with the membership system, it turns out that a person pays once and goes to a premium group, where all hidden sections are available to him.

Answer the question

In order to leave comments, you need to log in

2 answer(s)
A
Alexey Gorbunov, 2020-03-26
@kotboris

Simply, assign a user role when purchasing a product or sell access itself and at the same time change the role of the person who paid, for example:

add_action( 'woocommerce_order_status_completed', 'change_role_on_pro' );
function change_role_on_pro( $order_id ) {
    $order = wc_get_order( $order_id );
    $items = $order->get_items();

    $products_to_check = array( '3420' ); // id товара, при оплате которого меняется роль

    foreach ( $items as $item ) {
        if ( $order->user_id > 0 && in_array( $item['product_id'], $products_to_check ) ) {
        	$user = new WP_User( $order->user_id );

        	// заменить роль
        	$user->remove_role( 'customer' );
        	$user->remove_role( 'subscriber' );
        	$user->add_role( 'clientpro' );

            // окончание цикла
            break;
    	}
    }
}

Now, using any plugins from the Access category, you can set up restrictions on viewing content or entire pages / sections. Great plugin solution: Toolset Types Access

S
semki096, 2016-04-28
@semki096

Sell ​​posts as a unit of goods. I did something similar on Drupal - a very flexible drupal-commerce module, I have not seen analogues.

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question