I develop plugin for WordPress, and it represented in two versions: Free and Pro. For licensing used Freemius.
I've got many messages in support like a: "I can't activate Pro plugin, due to error: Cannot declare class A, because the name is already in use
".
So, users don't understand, that Free ver. need to be deactivated, before they activate Pro. Because it's look like user want to activate two plugins at same time.
I want to programmatically deactivate Free plugin, in process of activating Pro.
Of course, I tried to use deactivate_plugins() functions, and hook it in "register_activation_hook"
, but:
If I try to deactivate (for example Akismet) - it's working. I'm activate my plugin - Akismet is deactivating, but when I have activated my Free ver. of plugin, and tried to activate Pro - I getting same error - Cannot declare class ...
It's look like, that register_activation_hook
fire too late, and it have no time to deactivate Free before.
I'm sure this problem is being solved, but I can't figure out how. Please, share your experience.