I run a WooCommerce Store which utilises the WooCommerce memberships plugin to restrict content based on the users ‘plan’.

I want to display some conditional content (a banner including some text and image) based on the membership someone holds.

I am trying to think of a good way to do this.

My first thought was to create a long If / If Else function based on the membership plan of the user – but I don’t like this because it seems easy to mess up when editing. I’d like to isolate the content for each plan into a single file (e.g. silver.php for the Silver Plan).

The alternatives

1) Create a series of custom templates and use an array to output which one should be included. Something like

$allplans = array ('Silver' => 'silver.php', 'Gold' => 'gold.php');

$plan = 'Silver'; //This would be defined by a function detecting what plan the user is a member of;

$template = $allplans[$plan];

include $template;

2) Create a series of templates (one for each membership) and in each one hook a custom function to the relevant hook in WooCommerce.

add_action ('woocommerce_archive_description', 'custom_function', 11);

 function custom_function () {

    if (membership('Silver')) {

    // show some content here


What do people think? Any thoughts greatly appreciated.

Read more here: Conditional Content on WooCommerce Store Page


If you know the solution of this issue, please leave us a reply in Comment section, to update the question.

Wordpress related questions and answers: