Hi Sylvain, thank you for reaching out to the Paid Memberships Pro team.
PMPro v3.0 and v3.1 have included major changes to the front-end membership pages. We try and make site owners aware of these changes however it can sometimes slip between the cracks.
If you haven’t already, please consider signing up to our newsletter to ensure you’re kept in the loop (https://www.paidmembershipspro.com/live/), our Slack Community (https://www.paidmembershipspro.com/slack/) and subscribe to our Youtube Channel (https://www.youtube.com/channel/UCFtMIeYJ4_YVidi1aq9kl5g) as we frequently share the changes that have been made, new features and more on these channels.
You can also keep an eye on our Github Repo (https://github.com/strangerstudios/paid-memberships-pro) as all development changes go through here.
PMPro v3.1 also introduces a smartly generated message based on lots of conditions including whether the user is logged in, other Add Ons you have active in your site, the current user’s membership level, and the specific protection settings for the content being viewed.
If you had previously customized your messages, you can continue to edit them in Advanced Settings.
Docs: https://www.paidmembershipspro.com/documentation/content-controls/protected-content-messages/
To make this message as accurate as possible for all these conditions, we removed the ability for sites to edit their protected content messages in Advanced Settings. We highly recommend that most membership sites do not customize this message and leave the optimized default message in place.
For sites that had not customized the messages, you will not see a setting to make changes. We have a code recipe that can restore the field, but before we share that I’d like to know what you specifically want to adjust.
There are two new filters that can be used to adjust the heading of the box and body content of the box. I can give you an example code recipe for using this filters.
I hope this helps. Please feel free to reach out if you have any other questions or feedback for us.
Kind Regards,
Jarryd
Support Manager at Paid Memberships Pro
Because there have not been any recent updates to this topic, we will be changing the status to resolved. If you have any other questions regarding this issue please start a new topic for each question to ensure we can provide the best support possible.
If you’re enjoying Paid Memberships Pro, would you mind rating it 5-stars to help spread the word? https://wordpress.org/support/plugin/paid-memberships-pro/reviews/
Kind Regards,
Jarryd
Support Manager at Paid Memberships Pro
Hi @jarryd-long ,
We wrote at the same time! The planets are aligned. I reopened the thread.
Thank you for your detailed response and the various resources for staying updated with PMPro changes. I will definitely sign up for the newsletter and follow the GitHub repository.
Regarding my specific needs, I use the following snippet to customize the restriction message:
function custom_pmpro_non_member_message( $message ) {
$current_url = home_url(add_query_arg(array()));
$encoded_url = urlencode($current_url);
$login_url = home_url('/login/') . '?redirect_to=' . $encoded_url;
$register_url = home_url('/register/') . '?redirect_to=' . $encoded_url;
$new_message = "<div class=\"pmpro_content_message\"><p>Cette fonctionnalité est exclusivement réservée aux Membres inscrits. L'inscription est gratuite</p></div> <div><a class=\"btn-1\" href=\"{$login_url}\">Connectez-vous</a> <a class=\"btn-2\" href=\"{$register_url}\">Créer un compte gratuitement</a></div>";
return $new_message;
}
add_filter( 'pmpro_non_member_text_filter', 'custom_pmpro_non_member_message' );
add_filter( 'pmpro_not_logged_in_text_filter', 'custom_pmpro_non_member_message' );
This snippet works as intended since I disabled the “custom message” field in the settings. However, I’m left with an <h2> tag and the <div class=”pmpro_card_actions pmpro_font-medium”> that remain visible:
<div class="pmpro">
<div class="pmpro_card pmpro_content_message">
<h2 class="pmpro_card_title pmpro_font-large">
<svg xmlns="http://www.w3.org/2000/svg" width="24" height="24" viewBox="0 0 24 24" fill="none" stroke="var(--pmpro--color--accent)" stroke-width="2" stroke-linecap="round" stroke-linejoin="round" class="feather feather-lock">
<rect x="3" y="11" width="18" height="11" rx="2" ry="2"></rect>
<path d="M7 11V7a5 5 0 0 1 10 0v4"></path>
</svg>
Membre Membership Required
</h2>
<div class="pmpro_card_content">
<!-- my snippet message -->
<div class="pmpro_content_message">
<p>Cette fonctionnalité est exclusivement réservée aux membres inscrits. L'inscription est gratuite</p>
</div>
<div>
<a class="btn-1" href="/login/?redirect_to=https%3A%2F%2Fmon.site.com%2Fsuggerer%2F">Connectez-vous</a>
<a class="btn-2" href="/register/?redirect_to=https%3A%2F%2Fmonsite.com%2Fsuggerer%2F">Créer un compte gratuitement</a>
</div>
<!-- end of my snippet message -->
</div>
<div class="pmpro_card_actions pmpro_font-medium">
Déjà inscrit ? <a href="/login/?redirect_to=https%3A%2F%2Fmonsite.com%2Fsuggerer%2F">Connectez-vous ici</a>
</div>
</div>
</div>
I have temporarily hidden these elements using CSS but it’s not the best :
.pmpro-level-required .pmpro_card_title,
.pmpro-level-required .pmpro_card_actions {
display: none !important;
}
It seems that the <h2> tag with “Member required” is not translatable.
If I understand correctly, the filters pmpro_no_access_message_header and pmpro_no_access_message_body can help me modify the texts in the <h2> and the pmpro_card_actions pmpro_font-medium div?
Thank you again for your assistance.
Best regards,
-
This reply was modified 10 months, 1 week ago by
Reventlov.
@jarryd-long
In addition. I changed my code with the new filters you provided (pmpro_no_access_message_header and pmpro_no_access_message_body).
function custom_pmpro_no_access_message_header( $header, $level_ids ) {
$header = '<h2 class="pmpro_card_title pmpro_font-large">Accès réservé aux membres</h2>';
return $header;
}
add_filter( 'pmpro_no_access_message_header', 'custom_pmpro_no_access_message_header', 10, 2 );
function custom_pmpro_no_access_message_body( $body, $level_ids ) {
$current_url = home_url(add_query_arg(array()));
$encoded_url = urlencode($current_url);
$login_url = home_url('/login/') . '?redirect_to=' . $encoded_url;
$register_url = home_url('/register/') . '?redirect_to=' . $encoded_url;
$new_body = "<div class=\"pmpro_content_message\"><p>Cette fonctionnalité est exclusivement réservée aux membres inscrits. L'inscription est gratuite</p></div>
<div><a class=\"btn-1\" href=\"{$login_url}\">Connectez-vous</a>
<a class=\"btn-2\" href=\"{$register_url}\">Créer un compte gratuitement</a></div>";
return $new_body;
}
add_filter( 'pmpro_no_access_message_body', 'custom_pmpro_no_access_message_body', 10, 2 );
This code works well, but I encountered a few issues:
1. The SVG icon is encapsulated in an <h2> tag, which results in a duplicate <h2> tag:
<div class="pmpro">
<div class="pmpro_card pmpro_content_message">
<h2 class="pmpro_card_title pmpro_font-large">
<svg xmlns="http://www.w3.org/2000/svg" width="24" height="24" viewBox="0 0 24 24" fill="none" stroke="var(--pmpro--color--accent)" stroke-width="2" stroke-linecap="round" stroke-linejoin="round" class="feather feather-lock">
<rect x="3" y="11" width="18" height="11" rx="2" ry="2"></rect>
<path d="M7 11V7a5 5 0 0 1 10 0v4"></path>
</svg>
</h2>
<h2 class="pmpro_card_title pmpro_font-large">Accès réservé aux membres</h2>
<div class="pmpro_card_content">
<div class="pmpro_content_message">
<p>Cette fonctionnalité est exclusivement réservée aux membres inscrits. L'inscription est gratuite</p>
</div>
<div>
<a class="btn-1" href="https://monsite.com/login/?redirect_to=https%3A%2F%2Fmonsite.com%2Fsuggerer%2F">Connectez-vous</a>
<a class="btn-2" href="https://monsite.com/register/?redirect_to=https%3A%2F%2Fmonsite.com%2Fsuggerer%2F">Créer un compte gratuitement</a>
</div>
</div>
<div class="pmpro_card_actions pmpro_font-medium">Déjà inscrit ? <a href="https://monsite.com/login/?redirect_to=https%3A%2F%2Fmonsite.com%2Fsuggerer%2F">Connectez-vous ici</a></div>
</div>
</div>
2. The message inside the pmpro_card_actions pmpro_font-medium div persists, and I’m not sure how to remove or customize this part.
Could you please advise on how to address these issues?
Thank you for your help.
Best regards,`
Thank you for your feedback. As you need to change the structure of the no access card, I would recommend hooking into the pmpro_no_access_message_html
filter (https://github.com/strangerstudios/paid-memberships-pro/blob/master/includes/functions.php#L2200) and rebuilding the HTML in there instead.
Kind Regards,
Jarryd
Support Manager at Paid Memberships Pro