2014-09-18 209 views
0

我真的很掙扎(作爲一個PHP新手)來整理這段代碼並讓它工作(在wordpress語句中的語句)。希望你應該能明白我想要從代碼做我有如下:Tidyup PHP如果其他功能

感謝您的幫助......

<?php 
/** 
* The template for displaying Author archive pages 
* 
* @link http://codex.wordpress.org/Template_Hierarchy 
* 
* @package WordPress 
* @subpackage Twenty_Thirteen 
* @since Twenty Thirteen 1.0 
*/ 

get_header(); 

//phpinfo(); 
?> 

<div class="slider non-home"> 
<div class="homebanner"> 
<div class="home royalSlider"> 
<div class="rsImg"></div> 
</div> 
</div> 
</div> 
<div class="main" style="margin-top:20px;"> 
<div class="hundred"> 
<div class="page-header"> 
<?php $userID = intval($author); 
if(isset($_GET['author_name'])) : 
$curauth = get_userdatabylogin($author_name); 
else : 
$curauth = get_userdata(intval($author)); 
endif; ?> 
<ul class="profile-list"> 
<?php 
if ($curauth->_mgm_user_status; > 'expired') { 
echo " 
<li><strong>Status:</strong> <?php echo $curauth->_mgm_user_status; ?></li> 
<li><strong>Member No.:</strong> <?php echo $curauth->_mgm_cf_membership_id; ?></li> 
<li><strong>Title:</strong> <?php echo $curauth->_mgm_cf_title; ?></li> 
<li><strong>First Name:</strong> <?php echo $curauth->first_name; ?></li> 
<li><strong>Surname:</strong> <?php echo $curauth->last_name; ?></li> 
</ul> 

"; 
} else { 
echo "Sorry, this user has expired"; 
} 
?> 
</div> 
<div class="col13"> 
<?php if (!function_exists('dynamic_sidebar') || !dynamic_sidebar("page_sidebar")) : ?> 
<?php endif; ?> 
</div> 
</div> 
<?php get_footer(); ?> 

這一切都回聲併產生在前端的數據,但我只是無法得到這一切只顯示如果$ curauth - > _ mgm_user_status位等於'過期'。

+0

您在'<?php' – HddnTHA 2014-09-18 19:55:17

+0

裏面使用'<?php'除此之外,是否有任何問題或者下面的解決方案對我有幫助?儘管感謝您的幫助。 – dmt 2014-09-18 20:13:30

回答

2
if ($curauth->_mgm_user_status != 'expired') 
    { 
    echo "<li><strong>Status:</strong>".$curauth->_mgm_user_status."</li> 
    <li><strong>Member No.:</strong> ". $curauth->_mgm_cf_membership_id."</li> 
    <li><strong>Title:</strong> ". $curauth->_mgm_cf_title."</li> 
    <li><strong>First Name:</strong> ". $curauth->first_name."</li> 
    <li><strong>Surname:</strong> ". $curauth->last_name."</li> 
    </ul>"; 
    } 
else 
    { 
    echo "Sorry, this user has expired"; 
} 
+0

感謝您的幫助。不幸的是,即使用戶的狀態「已過期」,仍然顯示結果。 – dmt 2014-09-18 20:11:27

+0

我已經在我的author.php文件中預先添加了一些代碼 - 這是否會導致您的代碼出現問題? – dmt 2014-09-18 20:11:52

+1

條件語句非常簡單明瞭,請給我看完整的代碼.. – 2014-09-18 20:16:13

0

這工作:

if ($curauth->_mgm_user_status == 'Active') 

感謝卡邁勒!