Skip to content

Instantly share code, notes, and snippets.

@DimaMinka
Forked from campusboy87/set_acf_pro_license.php
Created November 18, 2019 07:57
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save DimaMinka/0266fdaa088b3bd294907d8edb77a86c to your computer and use it in GitHub Desktop.
Save DimaMinka/0266fdaa088b3bd294907d8edb77a86c 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