If she had an IUD inserted, then her period got longer, then she suffered prolonged non-menstrual bleeding, should she follow her cycle before the IUD or after it?
Question

                I had an IUD inserted about a year ago, and now my period lasts for approximately twelve days, whereas before it used to be seven or eight days. Please note that when it begins it is dark yellow trending towards brown, and is accompanied by cramps. That lasts for two days, then there is heavy bleeding for three or four days, and it begins to lighten until it becomes dark yellow or brown, and that carries on for a while. I do not know exactly when the period ends, but a while ago I heard that what is meant by dryness is inserting a piece of white cotton or a tissue and the like, and if there is any colour on it, that means that I have not become pure yet, and if there is no colour on it, then I have become pure [i.e., my period has ended]. I have been relying on this method to determine whether I have become pure or not, but I do not know whether it is correct or not. This month, on the second day of Shawwaal, the same thing happened: light discharge, then heavy bleeding, then it became yellow and light brown, but the brown discharge continued for a long time. About three days ago, the colour began to get darker again, so I inserted a piece of cloth and it came out dark brown. Should I do ghusl and pray? If we say that it is istihaadah, should I work out the times of my menses according to the natural cycle that I had before inserting the IUD or the cycle I had after that? Is it permissible to have intercourse in this situation?
Praise be to Allah.Firstly:
Menses can become longer or shorter, and its time can come earlier or later, especially when using contraceptive methods such as the IUD.
The end of the menses (“becoming pure”) may be determined by one of two signs:

the emission of the white discharge, which is something known to women;
complete dryness, such that if a piece of cotton or the like is inserted in that place, it comes out clean with no trace of blood or yellowish or brownish discharge on it.

Based on that, the method that you mention for determining whether your period had ended is correct.
Secondly:
If the yellowish or brownish discharge follows directly on from the menses, then they are regarded as menses.
So long as you did not see the white discharge, and you did not experience complete dryness, you are still menstruating, even if it is a few days longer than your usual period, so long as it is not continued for more than fifteen days. If it lasts for longer than fifteen days, then it is istihaadah [prolonged non-menstrual bleeding] according to the majority of fuqaha’.
What appears to be the case from the question is that you have not passed that limit.
Based on this view – that whatever lasts for more than fifteen days is istihaadah – if we assume that your period has lasted for more than fifteen days, then next month you should refrain from praying and so on for the duration of your usual period, then you should do ghusl and pray, and at that time it becomes permissible to have intercourse.
Your usual period in this case is what became the usual case after you had the IUD inserted, not before.
It says in Kashshaaf al-Qinaa‘ (1/208): If her usual menses becomes shorter, then she experiences irregular bleeding [istihaadah] after that, if her period was usually ten days, then her pattern changes and it lasts for seven days, then she experiences irregular bleeding after her pattern has changed, then she should refrain from praying and so on for seven days [regarding that as her menses], because that is what her new pattern is. End quote.
In order to confirm the duration of the period, it is not stipulated that it happened repeatedly, according to the correct view.
See: ash-Sharh al-Mumti‘ (1/497).
And Allah knows best.