Reputation: 91
I am trying to figure out where is my error in the following syntax. I am trying to use the If / Else statement to display contact info to managers and admins and info box in as div to everybody else :
<h2><?php _e( 'Manager Information', 'manager_suite' ); ?></h2>
<?php if( current_user_can('manager') || current_user_can('administrator') ) { ?> <!--show contact only to admins and managers -->
<ul class="list-unstyled">
<?php if ( !empty( $store_info['store_name'] ) ) { ?>
<li class="store-name">
<span><?php _e( 'Store Name:', 'manager_suite' ); ?></span>
<span class="details">
<?php echo esc_html( $store_info['store_name'] ); ?>
</span>
</li>
<?php } ?>
<li class="manager-name">
<span>
<?php _e( 'Store Contact:', 'manager_suite' ); ?>
</span>
<span class="details">
<?php printf( '<a href="%s">Visit Store</a>', get_store_url( $author->ID ), $author->display_name ); ?>
</span>
</li>
<li class="clearfix">
<?php get_readable_manager_rating( $author->ID ); ?>
</li>
</ul>
else <!--show this if user is not admin or manager -->
echo <div class="horizontal-notice">
You cannot see this manager details.
</div>
<?php } ?> <!--show contact only to admins and managers END-->
I definitely have several errors in this syntax - most probably with displaying the "Else" statement and also with the <ul>
. I think the <div>
is not displayed correctly either.
Can you please help correct my errors ?
Upvotes: 0
Views: 410
Reputation: 598
I'm not sure, but try replacing $product->post->post_author with $product->post_author
[UPDATE]
I didn't notice any error, but now I've seen the ending part of the code that contains some mistakes. Try this code.
<h2><?php _e( 'Manager Information', 'manager_suite' ); ?></h2>
<?php if( current_user_can('manager') || current_user_can('administrator') ) { ?> <!--show contact only to admins and managers -->
<ul class="list-unstyled">
<?php if ( !empty( $store_info['store_name'] ) ) { ?>
<li class="store-name">
<span><?php _e( 'Store Name:', 'manager_suite' ); ?></span>
<span class="details">
<?php echo esc_html( $store_info['store_name'] ); ?>
</span>
</li>
<?php } ?>
<li class="manager-name">
<span>
<?php _e( 'Store Contact:', 'manager_suite' ); ?>
</span>
<span class="details">
<?php printf( '<a href="%s">Visit Store</a>', get_store_url( $author->ID ), $author->display_name ); ?>
</span>
</li>
<li class="clearfix">
<?php get_readable_manager_rating( $author->ID ); ?>
</li>
</ul>
<?php } else { ?> <!--show this if user is not admin or manager -->
<div class="horizontal-notice">
You cannot see this manager details.
</div>
<?php } ?> <!--show contact only to admins and managers END-->
Upvotes: 1
Reputation: 161
echo <div class="horizontal-notice">
You cannot see this manager details.
</div>
Your echo statement creates a syntax error. Try surrounding it by '
s
Upvotes: 1
Reputation: 517
also your else statement is not even been looked at Try this (just posting the end part of ul)
</ul>
<?php
} else{ ?>
<!--show this if user is not admin or manager -->
<div class="horizontal-notice">
You cannot see this manager details.
</div>
<?php } ?> <!--show contact only to admins and managers END-->
Upvotes: 1