A student at the Adlai Stevenson HS complex in The Bronx was caught in October with seven baggies of marijuana — a violation that in prior years would have ­resulted in a criminal summons and a suspension.

Instead, a school safety officer handed the student a “warning card.” It asked politely: “Please bring this card home to your parent(s)/guardian so that you can discuss the matter with them.”

The pot was turned over to the NYPD, but the student’s name was listed as “John Doe.”

This is the brave new world of school discipline in New York City, where unruly kids rule: “They know they can get away with anything,” as several teachers put it.

Under a new discipline code launched by Mayor de Blasio and the Department of Education, inappropriate clothes, profanity and insubordination no longer trigger an automatic boot from the classroom.

Principals must get permission from the DOE’s Office of Safety and Youth Development before suspending a student for defying a teacher or other authority. “Minor physical ­altercations” no longer warrant a ­serious superintendent’s suspension.

As a result, suspensions by principals and superintendents dropped 17 percent citywide from 53,504 in 2013-14 to 44,626 in 2014-15.

The warning cards are being tested in a pilot program, launched during the summer of 2015 at 37 high schools, in partnership with the NYPD, the DOE said.

The warning cards go to students who engage in disorderly conduct such as yelling, cursing, fighting and assaults, or unlawful possession of marijuana. At Lehman HS, a student caught smoking pot in the restroom got a warning card.

The slip states, “You have committed a violation that could have resulted in the issuance of a criminal-court summons. You are receiving this warning card to give you an ­opportunity to correct your behavior within the school.”

It goes on to warn that a future violation “may result in your ­arrest,” and that the incident “has been referred to the school ­administration.” It then asks the student to bring the card home to his or her parents — although that’s not required. A DOE spokeswoman said schools “ensure that parents are apprised of all incidents” with a phone call.

The NYPD employees who safeguard schools worry that the policy handcuffs them and ­encourages misbehavior.

“This type of turning your back on illegal behavior is grooming criminals,” said Gregory Floyd, president of Teamsters Local 237, which represents school safety ­officers. He says students who get warning cards should have to pass a class on behavior, instead of getting off with a slap on the wrist.

“The mayor is saying crime is down in the schools,” Floyd said. “Crime is not disappearing. It’s just that we’re ignoring it.”

Safety officers have gotten little training on which offenses get a warning instead of a summons, Floyd said. The officers must first speak with their supervisors, who refer the incident to an NYPD lieutenant to decide whether a warning card is warranted.

Some incidents are especially troubling. At the Walton HS complex in The Bronx, a warning card was issued to a student who threatened to attack a safety officer, Floyd said.

At Evander Childs in The Bronx, at least 12 students have gotten warnings — eight for marijuana possession and four for disorderly conduct. Out-of-control kids erupted last Oct. 22 in a “near riot,” with boys and girls screaming, swinging wildly at each other and trying to capture the melee on smartphones.

Of the 20 high schools and middle schools that had the most suspensions in 2013-14, at least 10 cut the punishment by more than 50 percent in 2014-15, data obtained by The Post show.

Richmond Hill HS had the most suspensions citywide — 510 — in 2013-14, but only 133 in 2014-15, ranking 60th.

Richmond Hill is one of 93 struggling schools in de Blasio’s “Renewal program” under pressure to improve — and a lower suspension rate is one indicator of success. “If we don’t fix those numbers, we’re on the chopping block,” a staffer said.

Students who talk back at teachers, fight, roam the halls, or refuse to put away their cellphones are much less likely to be suspended, teachers at several schools said.

In November, Mary Bozoyan, a veteran math teacher at William Cullen Bryant HS in Astoria, Queens, told a boy loitering outside her classroom, gesturing to friends, to leave. “He went to backhand my face and stopped short, inches away,” Bozoyan recalled. “He said, ‘I didn’t hit you. You can’t do anything.’ ”

She reported the incident to a dean, but was never asked to fill out a report. “These kids don’t feel there’s any penalty,” Bozoyan said. “That’s serious — almost hitting a teacher — and they let him go.”

In a survey at a union meeting last week, United Federation of Teachers President Michael Mulgrew asked if students in their schools lost learning time as a result of other disruptive kids. Teachers answering yes: 81 percent.