Okay
  Public Ticket #2538493
Edit only own events (for woocommerce clients) and also sell tickets
Closed

Comments

  •  1
    formidaweb started the conversation

    Hello!


    1. I want to add the woocommerce clients as people who can publish calendars both from frontend and also admin.

    Searched through codecanyon answers, and found I must edit abstract.plugin.php in your plugin, and "replace edit_posts" with "read" for user permissions both at line 11 and 104.

    The solution works, is just what I wanted, however please guide me also to solve the two problems below (again, for woocommerce clients that will be the only wordpress users except admins on the website).


    2. How can the woocommerce clients also sell tickets through your plugin? Probably another .php file must be edited in your plugin...


    3. How can the woocommerce clients edit / delete only their own events? I tried this solutin (again, searched through codecanyon comments) but to no end result:


    add_filter('stec_admin_get_events', function($events) {

        // Super admin sees everything
        if (is_super_admin()) {
            return $events;
        }

        // Show only own events
        foreach ($events as $k => $event) {
            if ($event->get_author() !== get_current_user_id()) {
                unset($events[$k]);
            }
        }

        return array_values($events);
    });


    Please consider a solution that solves all three problems above concurrently. Maybe the solution at problem 1 (that works) is not compatible with what you are thinking of solving for me (problems 2 and 3).

    Thanks.

  •  771
    Zhivko replied

    Hi,

    What wordpress user role your clients have?


    Stachethemes Developer

  •  1
    formidaweb replied

    Woocommerce customer role is the only client / user role on the website, except wordpress admin


    https://docs.woocommerce.com/document/roles-capabilities/

  •  771
    Zhivko replied

    1) Remove any changes you've done to the calendar's core files.

    2) Add following filters in your theme or child-theme functions.php file.

    // Adds manage_woocommerce role to customers in order to create tickets
    add_filter('user_has_cap', function($give_permissions) {     $user = wp_get_current_user();
        if (in_array('customer', (array) $user->roles)) {
            $give_permissions['manage_woocommerce'] = 1;
        }     return $give_permissions;
    }); // Change calendar permission from edit_posts to manage_woocommerce
    add_filter('stec_permission', function() {
        return 'manage_woocommerce';
    }); // Enables admin dashboard for customers
    add_filter('woocommerce_prevent_admin_access', '__return_false');
    add_filter('woocommerce_disable_admin_bar', '__return_false'); add_action('plugins_loaded', function() {
        add_filter('woocommerce_admin_disabled', '__return_true');
    }); // Only super admin and events' author can see events in the back-end
    add_filter('stec_user_can_edit_event', function($null, $event_post) {     if (is_super_admin()) {
            return true;
        }     if ($event_post->get_author() === get_current_user_id()) {
            return true;
        }     return false;
    }, 10, 2);

    Keep in mind giving access to back-end poses security risks.


    Stachethemes Developer