PurposePrior research on user-generated content (UGC) contributions has primarily focused on self-centered or other-centered motives, paying limited attention to the concept of enlightened self-interest, in which both motives coexist in a single organism. Additionally, the factors influencing enlightened self-interest and their effects in different circumstances are yet to be explored. Drawing on theoretical lenses rooted in the switching barriers perspective and stimulus–organism–response framework, this study posits that dedication-based switching barriers (community–member relationship quality, member–member relationship quality, and content attractiveness) positively relate to enlightened self-interest, whereas constraint-based switching barriers (switching costs) moderate the relationship between dedication-based switching barriers and enlightened self-interest in social media communities (SMCs). Members' enlightened self-interest in turn influences both the creation and co-creation of UGC.Design/methodology/approachThis study comprised two quantitative studies: an online survey-based study (Study 1) and an online scenario-based experiment (Study 2). Study 1 surveyed 613 respondents, while Study 2 included 749 participants. Both studies employed structural equation modeling and bootstrapping techniques for analysis.FindingsThe findings indicate that dedication-based switching barriers positively affect users' enlightened self-interest, which in turn is positively associated with UGC creation and co-creation. Switching costs moderate the relationship between relationship quality (community–member and member–member) and enlightened self-interest.Originality/valueThis study complements the current understanding of how the association between dedication- and constraint-based switching barriers and users' enlightened self-interests influence user-generated contributions.