Question: What is the correct way to assign a (non-core) capability to a (non-core) role programmatically?
We are (finally) starting the upgrade process to 3.8.2 from 3.6.2. So it is a bit of a jump. But while most of our custom plugins are going through without a problem, 5 of the 73 are failing.
When calling assign_capability on a non-core capability via install.php, we're getting an exception that the capability doesn't exist. The error seems to be part of MDL-64971 that tries to make sure that capabilities exist when fetching. But custom capabilities (from the same plugin or others) don't yet exist.
So my question, how does one assign a capability at plugin install? What function should I be using instead of assign_capability nowadays?
We actually want to do this because we want to create a role programmatically and assign it a capability. I don't want to go through 20 different LMS installations and do anything manually. I can't add a capability via access.php unless it is to a role that is based on a core role (or has an archetype of a core role).
I'm sure that there is a proper way to do this that I'm just missing entirely... What is the best way to do this? I really would like to avoid altering the core file to avoid the check during initial install or creating my own version of assign capability and using that instead during install.