I'm having some problem with the function_is_user_logged_in. It can be seen on http://dev.cellarsale.co.za/index.php/listing/example-listing-2/ . I'm trying to make the "buy now" line disappear for unlogged people.
It's not working on my website for this part of code :
ob_start(); (...)
<table>
<tbody> (...)
<?php if(is_user_logged_in()){ ?>
<tr id="buynow" style="display: none;">
<td colspan="5" class="bidbox biddingbox">
<div class="wrap">
<span class="label label-default pull-right" onclick="jQuery('.biddingbox').hide();" ><?php echo $CORE->_e(array('account','48')); ?></span>
<hr />
<form method="post" action="" class="row clearfix" onsubmit="return CheckBidding();">
<input type="hidden" name="auction_action" value="newbid" />
<input type="hidden" name="bidtype" value="bid" />
<input type='hidden' name='hidden_cp' id='hidden_cp' value='<?php echo $current_price; ?>' />
<div class="col-md-4">
<div class="txtb"><?php echo $CORE->_e(array('auction','89')); ?></div>
</div>
<div class="col-md-4">
<div class='input-group'>
<input type='text' class='form-control' id='bid_amount' name="bidamount" placeholder='<?php echo ($current_price+1); ?>' />
<span class='input-group-addon'><?php echo $GLOBALS['CORE_THEME']['currency']['symbol']; ?></span>
</div>
</div>
<div class="col-md-2">
<button class="btn btn-lg btn-primary" type="submit"><?php echo $CORE->_e(array('auction','66')); ?></button>
</div>
</form>
<script>
function CheckBidding(){
<?php
if($userdata->ID && ($userdata->ID == $post->post_author && $userdata->ID != 1) ){ ?>
alert("<?php echo $CORE->_e(array('auction','72','flag_noedit')); ?>"); return false;
<?php }elseif($userdata->ID){ ?>
var bidprice = jQuery('#bid_amount').val();
var ecp = jQuery('#hidden_cp').val();
var ecp = Math.round(parseFloat(ecp)*100)/100;
var bidprice = Math.round(parseFloat(bidprice)*100)/100;
if(jQuery.isNumeric(bidprice) && bidprice > ecp){
return true;
}else{
alert('<?php echo $CORE->_e(array('auction','73','flag_noedit')).' '.$GLOBALS['CORE_THEME']['currency']['symbol']; ?>'+ecp+'');
return false;
}
<?php }else{ ?>
alert("<?php echo $CORE->_e(array('auction','56','flag_noedit')); ?>"); return false;
<?php } ?>
};
</script>
<hr />
<h4><?php echo $CORE->_e(array('auction','20')); ?></h4>
<?php echo $CORE->_e(array('auction','90')); ?>
<hr />
<p><?php echo $CORE->_e(array('auction','65')); ?></p>
<textarea><?php echo stripslashes($GLOBALS['CORE_THEME']['auction_terms']); ?></textarea>
</div>
</td>
</tr>
<?php } ?>
<?php } ?>
</tbody>
</table>
<?php
// RETURN OUTPUT
$output = ob_get_contents();
ob_end_clean();
return $output;
I think the ob_start() at the beginning might be the reason why it's not working but the thing is I used is_user_logged_in just above and it worked. I also tried to put all the content in the "if(is_userlogged_in)" : it was still working for the first part but not for the one just above.
I also tried at one point to hide it with css just to check using the code below:
It didn't work at all, for logged or unlogged people.
Does someone has any ideas please ?