Home › Forums › ACF PRO › Pro License Key in config? › Reply To: Pro License Key in config?
Yes this is still wanted. Recently had another large batch of websites lose their license keys. The custom code I previously used to reapply license keys stopped working. I assume something changed with the way ACF Pro activate license keys. I was able to get working by updating the custom code to match the code within ACF Pro itself.
// Check if ACF is running
if ( is_plugin_active( 'advanced-custom-fields-pro/acf.php' ) ) {
// Loads ACF plugin
include_once( ABSPATH . 'wp-content/plugins/advanced-custom-fields-pro/acf.php');
// connect
$post = array(
'acf_license' => "ACF_PRO_KEY",
'acf_version' => acf_get_setting('version'),
'wp_name' => get_bloginfo('name'),
'wp_url' => home_url(),
'wp_version' => get_bloginfo('version'),
'wp_language' => get_bloginfo('language'),
'wp_timezone' => get_option('timezone_string'),
);
// connect
$response = acf_updates()->request('v2/plugins/activate?p=pro', $post);
// ensure response is expected JSON array (not string)
if( is_string($response) ) {
$response = new WP_Error( 'server_error', esc_html($response) );
}
// success
if( $response['status'] == 1 ) {
acf_pro_update_license( $response['license'] ); // update license
}
echo $response['message']; // show message
}
Also wrote some code to make this automatically update after using a WP-CLI search-replace command. That’s typically where I’m seeing the license keys drop. https://anchor.host/2017/05/16/preloading-advanced-custom-fields-pro-license-key/
Welcome to the Advanced Custom Fields community forum.
Browse through ideas, snippets of code, questions and answers between fellow ACF users
Helping others is a great way to earn karma, gain badges and help ACF development!
We use cookies to offer you a better browsing experience, analyze site traffic and personalize content. Read about how we use cookies and how you can control them in our Privacy Policy. If you continue to use this site, you consent to our use of cookies.