Viewing 1 replies (of 1 total)
  • Thread Starter ekajuan

    (@ekajuan)

    I’ve solved it. My work around is to create a shortcode button, and a form. Put it on a page of your preference where only logged in user can see the page.

    On the hit of submit button, update the role to seller, and update the meta key: ‘dokan_enable_selling’ to yes on usermeta table.

    add_shortcode ('tombol_jadi_seller','jadi_seller');
    
    function jadi_seller() {
        if (current_user_can('contributor')) {
            echo '
            <form method="post">
                <input type="submit"  name="submit" value="Saya Ingin Jadi Seller" class="button">
            </form>';
        }
    }
    
    add_action ('wp_loaded', 'my_init');
    function my_init() {
        if (isset($_POST['submit'])){
            if (current_user_can('contributor')) {
                $id = get_current_user_id();
                $user = new WP_User( $id );
                $user->set_role( 'seller' );
                update_user_meta( $id, 'dokan_enable_selling', 'yes');
                wp_redirect (get_site_url().'/dashboard');
                exit;
             }
        }
    }
Viewing 1 replies (of 1 total)
  • The topic ‘If a customer want to be a seller how to do that?’ is closed to new replies.