The link prediction problem is becoming an important area of online social network (OSN) research. The existing methods that have been developed to address this problem mostly try to predict links based on structural information about the whole of the user lifespan. In addition, most of them do not consider user attributes such as user weight, density of interaction and geodistance, all of which have an influence on the prediction of future links in OSNs due to the human-centric nature of these networks. Moreover, an OSN is a dynamic environment because users join and leave communities based on their interests over time. Therefore, it is necessary to predict links in real time. Therefore, the current study proposes a new method based on time and user attributes to predict links based on changes in user communities, where the changes in the user communities are indicative of users’ interests. The proposed method is tested on the UKM dataset and its performance is compared with that of 10 well-known methods and another community-based method. The area-under-the-curve results show that the proposed method is more accurate than all of the compared methods.