Skip to content

Instantly share code, notes, and snippets.

@supercleanse
Created March 31, 2014 16:51
Show Gist options
  • Save supercleanse/9896724 to your computer and use it in GitHub Desktop.
Save supercleanse/9896724 to your computer and use it in GitHub Desktop.
An example of rendering a nav bar with links for only the products the current user is active on.
<ul class="nav">
<?php
$product_ids = array( 'Bronze' => 1812,
'Silver' => 8171,
'Gold' => 4191 );
foreach( $product_ids as $label => $id ) {
if(current_user_can("memberpress_product_authorized_{$id}")) {
$product = new MeprProduct($id);
?>
<li class="nav-item"><a href="<?php echo $product->access_url; ?>"><?php echo $label; ?></a></li>
<?php
}
}
?>
</ul>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment