acf_pro::invalid_license_redirect
Redirects back to the list table when editing an unauthorized item with an invalid license.
Method of the class: acf_pro{}
No Hooks.
Returns
null. Nothing (null).
Usage
$acf_pro = new acf_pro(); $acf_pro->invalid_license_redirect( $post_type );
- $post_type(string) (required)
- The post type being edited.
Changelog
| Since 6.2.8 | Introduced. |
acf_pro::invalid_license_redirect() acf pro::invalid license redirect code ACF 6.8.8
public function invalid_license_redirect( string $post_type ) {
if ( ! in_array( $post_type, array( 'acf-field-group', 'acf-ui-options-page' ), true ) ) {
return;
}
// Active licenses have no restrictions.
if ( acf_pro_is_license_active() ) {
return;
}
// The post being edited.
$current_post = (int) acf_request_arg( 'post', 0 );
if ( 'acf-ui-options-page' === $post_type ) {
// Only existing options pages can be edited with an expired license.
if ( $current_post && acf_pro_is_license_expired() ) {
return;
}
} elseif ( 'acf-field-group' === $post_type ) {
// Expired licenses can edit new/existing field groups regardless of block locations.
if ( acf_pro_is_license_expired() ) {
return;
}
// No block locations, should still be able to edit.
if ( ! acf_field_group_has_location_type( $current_post, 'block' ) ) {
return;
}
}
// Redirect back to field groups list table.
wp_safe_redirect( admin_url( 'edit.php?acf_invalid_license=true&post_type=' . $post_type ) );
exit;
}