All Topics
Disable inline edit based on custom field
HI,
I am trying to disable inline edit if field wpcf-organic-traffic is set to 1.
I can’t figure out why my custom code is not working, any ideas as to why, is the hook still available?
function my_acp_disable_inline_editing($editable, AC\Column $column) {
if ($column->get_type() === 'status') {
$post_id = $column->get_id();
// Retrieve the value of the custom field 'wpcf-organic-traffic'
$organic_traffic_value = get_post_meta($post_id, 'wpcf-organic-traffic', true);
// Check if 'wpcf-organic-traffic' is set to 1
if ($organic_traffic_value === '1') {
return false; // Disable inline editing
}
}
return $editable;
}
add_filter('acp/editing/view', 'my_acp_disable_inline_editing', 10, 2);
Thanks.
You must be logged in to reply to this topic.