Broadly, the California Family Code allows the court, during the divorce or at anytime thereafter, to make an order for the custody of a child during minority "that seems necessary or proper." [Ca Fam § 3022]. The court uses two basic criterias:1. Safety & Welfare: The court's main concern is to assure the child's health, safety and welfare. 2. "Frequent and continuing contact" with both parents and shared parenting.I don't think adultery by itself would stop you from getting the child custody.