Last active
April 15, 2021 16:31
-
-
Save Stiofan/4e584d43f3980f052c5b65ae4f932625 to your computer and use it in GitHub Desktop.
Custom field to enable or disable comments
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?php // <-- you probably dont need this line | |
add_action('geodir_after_save_listing','_my_update_comment_settings_on_save',10,2); | |
function _my_update_comment_settings_on_save($last_post_id, $request_info){ | |
global $wpdb; | |
if(isset($request_info['geodir_allow_comments']) && $request_info['geodir_allow_comments']=='1'){ | |
$wpdb->query($wpdb->prepare("UPDATE $wpdb->posts SET comment_status = 'open' WHERE ID = %d", $last_post_id)); | |
}elseif(isset($request_info['geodir_allow_comments']) && $request_info['geodir_allow_comments']=='0'){ | |
$wpdb->query($wpdb->prepare("UPDATE $wpdb->posts SET comment_status = 'closed' WHERE ID = %d", $last_post_id)); | |
} | |
} |
@leem2209 no, that was for GDv1, in GDv2 it is "geodir_post_saved" and a little different. I don't think we send that godire_allow_comments now so you would need a different trigger https://github.com/AyeCode/geodirectory/blob/master/includes/class-geodir-post-data.php#L702
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
does geodir_after_save_listing still work?