You didn’t provide enough information. Temperature and pressure are important factors to consider. I think that a magnet on a planet with a temperature on or about absolute zero (0 degrees Kelvin) would not function. Also if the temperature was that of the melting point of iron you would have a very poor functioning magnet.
What if the planet was falling into the colossal forces of the singularity of a black hole where light cannot escape?