Skip to content

Instantly share code, notes, and snippets.

@nickpish
Last active January 15, 2025 15:50
Show Gist options
  • Save nickpish/b2604e8032aba47b8d6fe37df6d96100 to your computer and use it in GitHub Desktop.
Save nickpish/b2604e8032aba47b8d6fe37df6d96100 to your computer and use it in GitHub Desktop.
Function to update post meta for Personnel posts w/ BNFW plugin
<?php
function wes_update_personnel_notifications() {
// set args to query all Personnel posts
$args = array(
'post_type' => 'personnel',
'post_status' => 'any',
'posts_per_page' => -1,
);
$personnel_posts = get_posts( $args );
foreach ( $personnel_posts as $post ) {
$post_id = $post->ID;
// update override field
if ( metadata_exists( 'post', $post_id, '_bnfw_override_23939' ) ) {
update_post_meta( $post_id, '_bnfw_override_23939', true );
}
// update enable notification field
if ( metadata_exists( 'post', $post_id, '_bnfw_enable_23939' ) ) {
update_post_meta( $post_id, '_bnfw_enable_23939', true );
}
}
}
add_action( 'init', 'wes_update_personnel_notifications' );
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment