Skip to content

Instantly share code, notes, and snippets.

@campusboy87
Last active December 12, 2019 19:10
Show Gist options
  • Save campusboy87/fbf4c74d70b3453253b1c1e741a51350 to your computer and use it in GitHub Desktop.
Save campusboy87/fbf4c74d70b3453253b1c1e741a51350 to your computer and use it in GitHub Desktop.
Automatic activation of ACF license via PHP. The code adds the key to the option in the desired format, and adds the domain to the list of trusted domains tracked in the ACF profile, so that the update is successful. The code can be used as a MU plugin, a regular plugin, or inserted into the theme code.
<?php
add_action( 'acf/init', 'set_acf_pro_license' );
function set_acf_pro_license() {
global $acf_instances;
if ( isset( $acf_instances['ACF_Admin_Updates'] ) && ! get_option( 'acf_pro_license' ) ) {
/**
* @var ACF_Admin_Updates $acf
*/
$acf = $acf_instances['ACF_Admin_Updates'];
$_POST['acf_pro_licence'] = 'YOUR_LICENCE_KEY';
$acf->activate_pro_licence();
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment