setup_actions(); } /** * Setup the admin hooks, actions and filters * * @return void */ function setup_actions() { // Bail if in network admin if ( is_network_admin() ) { return; } // User profile edit/display actions add_action( 'erp_user_profile_role', array( $this, 'role' ) ); add_action( 'erp_update_user', array( $this, 'update_user' ), 10, 2 ); //notification disable checkbox add_action( 'edit_user_profile', [ $this, 'profile_settings' ] ); add_action( 'show_user_profile', [ $this, 'profile_settings' ] ); add_action( 'erp_update_user', [ $this, 'update_profile_settings' ], 10, 2 ); } function update_user( $user_id, $post ) { // HR role we want the user to have $new_hr_manager_role = isset( $post['hr_manager'] ) ? sanitize_text_field( $post['hr_manager'] ) : false; if ( ! $new_hr_manager_role ) { return; } // Bail if current user cannot promote the passing user if ( ! current_user_can( 'promote_user', $user_id ) ) { return; } // Set the new HR role $user = get_user_by( 'id', $user_id ); if ( $new_hr_manager_role ) { $user->add_role( $new_hr_manager_role ); } else { $user->remove_role( erp_hr_get_manager_role() ); } } function role( $profileuser ) { if ( ! current_user_can( 'manage_options' ) ) { return; } $checked = in_array( erp_hr_get_manager_role(), $profileuser->roles ) ? 'checked' : ''; ?> ID, 'erp_hr_disable_notification', true ); $checked = ! empty( $notification ) ? 'checked' : ''; ?>
| name="erp_hr_disable_notification"> |