Skip to content

Instantly share code, notes, and snippets.

@mattradford
Last active October 28, 2023 19:25
Show Gist options
  • Star 33 You must be signed in to star a gist
  • Fork 9 You must be signed in to fork a gist
  • Save mattradford/6d5b8f3cd11ce1f62480 to your computer and use it in GitHub Desktop.
Save mattradford/6d5b8f3cd11ce1f62480 to your computer and use it in GitHub Desktop.
ACF5 Pro licence activation. Could be adapted for any other plugin that requires a licence key, but doesn't yet support defining it in wp-config. Fires on theme activation.
// Place this in wp-config
define( 'ACF_5_KEY', 'yourkeyhere' );
// Set ACF 5 license key on theme activation. Stick in your functions.php or equivalent.
function auto_set_license_keys() {
if ( ! get_option( 'acf_pro_license' ) && defined( 'ACF_5_KEY' ) ) {
$save = array(
'key' => ACF_5_KEY,
'url' => home_url()
);
$save = maybe_serialize($save);
$save = base64_encode($save);
update_option( 'acf_pro_license', $save );
}
}
add_action( 'after_switch_theme', 'auto_set_license_keys' );
@sasqik
Copy link

sasqik commented Mar 14, 2020

My version, filtering on the get_option function for that specific option_name https://gist.github.com/polevaultweb/9cdf1b3bfeb054f13f221d4612bd8901

You should remember to give everybody know to add this in wp-config.php. Then it will work correctly.

// Place this in wp-config
define('ACF_PRO_LICENSE', 'yourkeyhere' );

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment