我试图找出以下语法中的错误在哪里。我正在尝试使用If / Else语句向管理员和管理员显示联系信息,并将信息框显示为div给其他人:
<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-->
我在这种语法中肯定有几个错误 - 很可能是显示“Else”语句以及<ul>
。我认为<div>
也没有正确显示。
请帮助纠正我的错误?
答案 0 :(得分:1)
我不确定,但尝试用$ product-&gt; post_author替换$ product-&gt; post-&gt; post_author
<强> [UPDATE] 强>
我没有注意到任何错误,但现在我已经看到代码的结尾部分包含一些错误。试试这段代码。
<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-->
答案 1 :(得分:1)
你的其他语句甚至没有看过试试这个(只发布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-->
答案 2 :(得分:1)
echo <div class="horizontal-notice">
You cannot see this manager details.
</div>
您的echo语句会产生语法错误。请尝试'
s