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="https://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 3 months, 2 weeks ago by Reventlov.