Advertisement
Guest User

Untitled

a guest
Jun 19th, 2019
105
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.75 KB | None | 0 0
  1. <?php
  2. /**
  3. * This changes email settings after someone logs in to force specific settings for everyone.
  4. */
  5. function wp_256_change_email_settings_after_login( $user_login, $user ) {
  6. // get roles data
  7. $user_info = get_userdata( $user->ID );
  8.  
  9. // if project_client role, turn off comment notifications
  10. foreach ( $user_info->roles as $role ) {
  11. if ( 'project_client' === $role ) {
  12. update_user_meta( $user->ID, 'ph_comments', 'off' );
  13. update_user_meta( $user->ID, 'ph_image_approvals', 'off' );
  14. update_user_meta( $user->ID, 'ph_project_approvals', 'off' );
  15. update_user_meta( $user->ID, 'ph_resolves', 'off' );
  16. update_user_meta( $user->ID, 'ph_assigns', 'off' );
  17. }
  18. }
  19. }
  20. add_action('wp_login', 'wp_256_change_email_settings_after_login', 10, 2);
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement