Skip to main content

Is there a hook or filter to replace the Follow/Unfollow success messages?

Hi everyone,

I'm building a custom WordPress plugin that extends the FluentCommunity Followers Pro feature.

I've successfully implemented follower limits based on membership levels, and the plugin can modify the REST response messages for follow and unfollow actions.

For example, if a user follows someone, my plugin can return a custom success message instead of the default "Successfully followed user" message.

The issue is that FluentCommunity still displays its own default frontend notification/toast message rather than the custom message being returned by the API.

Has anyone found a supported way to:

  • Override the default follow/unfollow success messages?
  • Hook into the frontend notification/toast system?
  • Listen for follow/unfollow events in JavaScript?
  • Replace the default notification text from a custom plugin without editing FluentCommunity core files?

Any pointers to hooks, filters, actions, JS events, or documentation would be greatly appreciated.

Thanks!

Thanks for the post, we will look into this and give you an update.

Thomas Oates

This should work if the text is the same for everyone.

add_filter('gettext', 'custom_text', 10, 3);
function custom_text($translated_text, $untranslated_text, $domain) {
    if ('Successfully followed user' == $translated_text) {
        return 'Hey! You followed someone.';
    }
    return $translated_text;
}

1.00

Lawrence 890

Thomas OatesΒ Thanks. Would this also work for replacing the follow and unfollow toast notifications generated by the Followers Pro frontend, or is there a FluentCommunity-specific hook/filter that would be preferable?

Thomas Oates

Lawrence 890Β I'm not sure I fully understand the question. By 'Followers Pro", do you mean the Follower module in FluentCommunity or an add-on plugin? If the former, the code above does change the toast notifications. The screenshot I posted is exactly that after I enabled the Follower module in my test site and deployed the code. You could add additional if () lines for other strings of text.
Let me know if I'm misunderstanding what you're asking. Thanks.

Lawrence 890

Thomas OatesΒ Thanks Thomas, that makes sense. Yes, I meant the built-in Follower module in FluentCommunity. Your gettext approach has worked for replacing the follow/unfollow toast messages from my custom plugin. I’ll add extra string checks if I need to replace any others. Appreciate the help.