With the increasing demand for sustainable and resource-efficient wastewater treatment technologies, particularly in addressing metal−organic complexes contamination, herein we present a photoelectrochemical (PEC) wastewater treatment system based on a solar-driven ion confinement strategy. Employing a coordination polymer framework known as copper hexacyanoferrate (CuFe Prussian blue analogues (PBA)) as the host material for ion confinement, our strategy creates a pathway that couples photogenerated electrons with heavy-metal ions. This facilitates rapid electron transfer, enabling the effective separation of charge carriers and simultaneous capture of Cu(II) from wastewater. Taking Cu-ethylenediaminetetraacetic acid (EDTA) as a model pollutant, our proposed method demonstrates a removal efficiency of 92.2% for Cu-EDTA complexes and a recovery rate of 76.5% for Cu(II) under unbiased conditions. Analysis using X-ray absorption fine structure (XAFS) confirms the ion confinement of Cu(II) within the structure, distinguishing it from traditional PEC methods that focus on obtaining elemental Cu(0). Controlled release of metal ions not only meets specific requirements but also has significant potential for chemical recovery. Our proposed technology embodies the concept of utilizing pollutants to treat pollutants, making full use of concomitant heavy-metal ions in wastewater. It concurrently achieves the efficient degradation of organic pollutants while also facilitating resource recovery.