Okay
  Public Ticket #4368985
Improvement Request – User Deletion Control in Staff Management
Closed

Comments

  •  5
    Naoki Onodera started the conversation

    Dear MarketKing Team,

    I would like to kindly suggest an improvement regarding the staff management functionality in MarketKing.

    Background

    At present, when a vendor deletes a staff member via the staff management screen,
    wp_delete_user($team_member_id) is called, which physically deletes the entire WordPress user account.

    This behavior goes beyond the original intent of simply removing the staff member from the store team, and it also affects the user’s rights as a regular customer of the site (such as receiving orders, accessing downloads, and managing subscriptions).

    For example, if a customer places an order and is later deleted as a user, they would no longer be able to access their purchase, which could easily lead to complaints or operational issues.

    Suggested Improvement

    We would kindly request the addition of an option in MarketKing > Settings:

    “Allow staff deletion” (ON/OFF)

    • ON: Current behavior (staff deleted as WordPress users)

    • OFF: Instead of deletion, staff status is switched (Approved ⇄ Hold → Deregistered)

    Ideally, this should be a settings option, but at minimum, it would already be very useful if this behavior could be controlled via a filter hook (ON/OFF).

    Staff Status Management (when “Allow staff deletion” = OFF)

    We believe it would be beneficial if staff accounts could also be managed with the same key as vendors:
    marketking_account_approved, along with an additional dedicated flag for staff applications:
    marketking_staff_application_pending.

    Proposed Staff States:

    1. Approved staff (when vendor registers staff)

    • marketking_staff_application_pending = no

    • marketking_account_approved = yes

    1. On hold (temporarily suspended by vendor, e.g. long-term leave; still part of the vendor’s team)

    • marketking_staff_application_pending = no

    • marketking_account_approved = pending

    1. Deregistered (store affiliation removed; no longer part of the team, but historical record is preserved)

    • marketking_staff_application_pending = no

    • marketking_account_approved = no

    • parent_vendor = vendor_id (kept for audit trail)

    Notes:

    • For deregistered staff, we suggest keeping the parent_vendor value (instead of clearing it) so it is clear from which vendor the user was removed.

    • Current team queries should always be filtered with marketking_account_approved = (yes or pending).

    • For vendors, the existing marketking_vendor_application_pending continues unchanged.

    Staff Login Control

    If “Allow staff deletion” is set to OFF, add a login check for staff accounts in the vendor dashboard:

    • Only yes (Approved) staff may log in

    • pending (Hold) and no (Deregistered) staff should not be able to log in

    Supplementary Points

    • Consistency with vendor approval
      MarketKing core already includes a vendor approval system. Using similar keys for staff ensures consistency and provides a solid foundation for future extensions in account management.

    • Preserving audit trails
      Physically deleting WordPress users removes all historical data, making post-incident investigation difficult. By controlling status instead, accounts are preserved while access is restricted.

    • Minimal impact on existing sites
      By default, the current behavior (user deletion) remains unchanged.
      The new status workflow (Approved ⇄ Hold → Deregistered) will only apply if the admin changes the setting, ensuring backward compatibility.

    We believe this improvement would be valuable for other users as well, and we are confident it will enhance both the reliability and flexibility of staff management in MarketKing.

    We would be very grateful if you could kindly consider this request.

    Best regards,

  •  2,591
    WebWizards replied

    Hi Naoki,

    Thank you for your detailed feedback! While we're working on implementing this as a full setting in a future update, I've added a hook that can help you achieve this functionality right now.

    Please update to the latest version of MarketKing Core, and then you can use this code snippet to prevent user deletion and instead just remove the team member connection:

    add_filter('marketking_delete_team_member','__return_false');
    add_action('marketking_delete_team_member_action', function($user_id){
        // remove connection 
        update_user_meta($user_id, 'marketking_parent_vendor', '');
    }, 10, 1);

    This code can be added to your theme's functions.php file or through a code snippets plugin.

    You can further modify this code if you wish, e.g. to save historical data for example.

     

    Let me know if you need any clarification,

    Kind regards,
    Stefan

    Attached files:  marketking-core-2094.zip

  •  5
    Naoki Onodera replied

    Hello MarketKing Team,

    Thank you once again for your quick response and for already adding the filter/hook to prevent staff user accounts from being deleted.
    This is already extremely helpful and allows for much more flexible operations.

    Since staff turnover can be quite frequent, being able to manage staff through status changes (rather than only terminating them) would make operations smoother and safer.

    To better understand the future direction of this feature, I would like to ask: within your current plans, to what extent do you expect to support staff status management?
    From my understanding, the possibilities could be:

    • Approved / Hold

    • or Approved / Deregistered only

    • or Deregistered only (removing vendor connection)

    At present, the snippet is limited only to “Deregistered,” but even if the official release also remains limited to “Deregistered,” it would still be extremely useful if the registration and deregistration processes include extension hooks that allow status changes.

    If you are considering supporting “Approved / Hold / Deregistered,” that would be ideal.
    In that case, I believe it will also be necessary to cover various scenarios, such as adding login checks in the vendor dashboard (so that only “Approved” staff can log in) or allowing vendors to switch staff statuses (e.g., to “Hold” or “Deregistered”) directly from the staff list.
    If more detailed case studies are needed, I would be glad to cooperate via private chat.

    Thank you very much again for your support and for considering this request.

    Best regards,
    Naoki

  •  2,591
    WebWizards replied

    Hi Naoki,

    Thank you for your detailed follow-up. I want to clarify that currently we don't have functionality for multiple staff statuses (Approved/Hold/Deregistered) in our development plans, and implementing such a system would require significant custom development.

    However, you can achieve some of what you're looking for by customizing the code snippet I provided earlier and modifying the teams.php template in the vendor dashboard. For example, you could:

    1. Store additional meta data about staff status
    2. Add custom logic for login restrictions
    3. Maintain historical records of staff changes

    That said, since this would involve custom development, we can provide technical guidance but the implementation would need to be handled by your development team.

    Let me know if you need any clarification or any hooks or technical information.

    Kind regards,
    Stefan