Advertisement
vapvarun

Automatically disable notifications for users without the 'Niveau-3' tag

May 20th, 2024
81
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.66 KB | None | 0 0
  1. /**
  2. * Automatically disable notifications for users without the 'Niveau-3' tag.
  3. */
  4. add_action( 'init', function() {
  5. // Check if the 'wpf_has_tag' function exists before proceeding
  6. if ( ! function_exists( 'wpf_has_tag' ) ) {
  7. return;
  8. }
  9.  
  10. // Get all users
  11. $users = get_users();
  12.  
  13. // Loop through each user
  14. foreach ( $users as $key => $user ) {
  15. // Check if the user does not have the 'Niveau-3' tag
  16. if ( ! wpf_has_tag( 'Niveau-3', $user->ID ) ) {
  17. // Update the user's meta to disable notifications
  18. update_user_meta( $user->ID, 'enable_notification', 'no' );
  19. }
  20. }
  21. });
  22.  
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement