Write a SYSTEM_EVENT_AP_STACONNECTED system event handler. This is shown in practically every example: your own event handler is set by esp_event_loop_init. As a parameter for the event handler you get the MAC address of the connected station (there will be something to know by) and its aid, i.e. there will be something to substitute into the esp_wifi_deauth_sta function.