Sometimes, there is no viable option for a client in criminal proceedings except to plead guilty. However, what appears to be a "good deal" for a U.S. Citizen may in fact be fatal for a Legal Permanent Resident/undocumented immigrant and in certain instances, will result in him/her placed in removal proceedings. Therefore, counsel representing the client must take great care and have a detailed understanding of the nuances of immigration law. California law, as well as the Supreme Court, has held that criminal defense counsel has an affirmative duty to inform his/her client of the immigration consequences of his guilty plea. People v. Soriano, 194 Cal. App. 3d 1470 (1987). See also Padilla v. Kentucky, 130 U.S. 1473 (2010).
Criminal defense counsel could to a list of investigatory actions to determine the immigration consequences of his/her client pleading guilty. This includes researching the law, consulting with experienced immigration counsel, or simply have his/her client consult with immigration consult. California courts, as well as the Supreme Court has held that failure to do so constitutes ineffective assistance of counsel in violation of the 6th Amendment of the U.S. Constitution.
If the client is placed in removal proceedings, he/she could very well be ineligible for relief based on his/her conviction. At that point, a remedy called "post-conviction relief" would have to be employed where the client's attorney essentially attempts to re-open the criminal case and change/withdraw the client's guilty plea based on ineffective assistance of counsel. One such common measure in California is known as a 1018 Motion, or a "Motion to Vacate a Criminal Judgment in California." Another is a writ of Habeas Corpus, though the client would need to still be in actual or constructive custody (such as parole or released from custody on bail).
For more information on immigration consequences of guilty criminal pleas, please refer to www.ilrc.org/crimes.