Simple Membership Plugin › Forums › Simple Membership Plugin › Different partial protection custom messages for logged-out vs expired members
Tagged: Custom msg
- This topic has 3 replies, 3 voices, and was last updated 7 months, 1 week ago by
Fred.
-
AuthorPosts
-
August 22, 2025 at 10:13 am #31331
Izabella
ParticipantHello,
I’m using the following shortcodes to partially protect my content:
[swpm_protected for=”3-4″ account_status=”active” custom_msg=”This content is available only with Premium access.”]
Premium content here…
[/swpm_protected]The problem is if a user is logged-out OR if is logged-in but their membership has expired, both cases see the same message.
What I need is to show a different message for logged in expired members, like “Your Premium membership has expired. Please renew to regain access.”
I can’t find a way to differentiate between these two states (logged-out vs logged-in expired).
Is there an existing shortcode that allows me to show different messages for logged-in expired members and for not-logged-in visitors?
Thank you in advance for your help!
August 23, 2025 at 12:17 am #31334The Assurer
ModeratorYou’re right — the [swpm_protected] shortcode lets you show a single custom message (custom_msg) when access is denied, but it does not differentiate why access was denied (logged-out vs. logged-in but expired).
Out of the box, the plugin does not have a shortcode that displays different messages for expired members versus logged-out visitors. Both cases fall under “not authorized to view.”
Available Options
- Use [swpm_show_if_logged_in] / [swpm_show_if_notlogged_in]
You can wrap content in these conditionals to separate logged-in from logged-out visitors. For example:[swpm_show_if_notlogged_in]
Please log in or sign up to view this content.
[/swpm_show_if_notlogged_in][swpm_show_if_logged_in]
[swpm_protected for=”3-4″ account_status=”active” custom_msg=”Your Premium membership has expired. Please renew to regain access.”]
Premium content here…
[/swpm_protected]
[/swpm_show_if_logged_in]Logged-out visitors will see the first message.
Logged-in users will hit the [swpm_protected] check — active members see content, expired members see your “renew” message.
👉 This setup effectively gives you the split behavior you’re looking for.
- Custom PHP shortcode (if you want more control)
If you’d like to detect “expired” more directly, you can create a custom shortcode that checks the current member’s status. The plugin provides helper functions like:SwpmMemberUtils::is_member_logged_in();
SwpmMemberUtils::get_user_info_by_id($member_id);A small custom addon could output one message for account_status=expired and another for not logged in.
✅ The first shortcode-only method should solve your case without coding.
August 23, 2025 at 1:12 pm #31336Izabella
ParticipantThank you for your support.
The [swpm_show_if_logged_in] / [swpm_show_if_notlogged_in] shortcodes doesn’t trigger anything, but I managed to follow your logic and now this works:
### Not logged in members message:
[swpm_protected visible_to=”not_logged_in_users_only” do_not_show_protected_msg=”1″]
Please log in or sign up to view this content.
[/swpm_protected]### Expired members message:
[swpm_protected account_status=”expired” do_not_show_protected_msg=”1″]
Your Premium membership has expired. Please renew to regain access.
[/swpm_protected]### Partial protection:
[swpm_protected for=”3-4″ account_status=”active” do_not_show_protected_msg=”1″]
Premium content here…
[/swpm_protected]December 4, 2025 at 12:18 pm #31789Fred
ParticipantHi,
Ihave a small problem with SMP, I am in France and select the french language.
When I try to acces a protected page when I am not connected, I have the normal message:“You need to be logged in to view this content. Veuillez Log In. Not a Member? Nous Rejoindre”
I tried to find the file to translate theses word, but I can’t find it (I look at frenc.po etc…)
Another question, where I can find this two files you talk about:
[swpm_show_if_notlogged_in] and [/swpm_show_if_notlogged_in]Thank you for your reply
Best regards - Use [swpm_show_if_logged_in] / [swpm_show_if_notlogged_in]
-
AuthorPosts
- You must be logged in to reply to this topic.