Advertisement:

Author Topic: Hide Phone Number + name IF user is not logged in [SOLVED]  (Read 1451 times)

ben_dchost1

  • Jr. Member
  • **
  • Posts: 92
Hide Phone Number + name IF user is not logged in [SOLVED]
« on: June 25, 2014, 03:21:06 pm »
I want to hide the contact details of the publisher/seller if the user is not logged in. In other words, the only way a user can find out the contact details is if the user is logged in. I have attached an image which shows what I want to hide from non-logged in users.

Thanks
« Last Edit: June 26, 2014, 01:04:05 pm by ben_dchost1 »

design

  • Hero Member
  • *****
  • Posts: 2619
  • Osclass 3.5 MAC/PC w/ Modern Browsers
Re: Hide Phone Number + name IF user is not logged in
« Reply #1 on: June 25, 2014, 06:07:16 pm »
add this before the field and don't forget to close the bracket after the field

<?php if ( osc_is_web_user_logged_in()  ) { ?>

your code

} ?>


ben_dchost1

  • Jr. Member
  • **
  • Posts: 92
Re: Hide Phone Number + name IF user is not logged in
« Reply #2 on: June 26, 2014, 01:03:20 pm »
add this before the field and don't forget to close the bracket after the field

<?php if ( osc_is_web_user_logged_in()  ) { ?>

your code

} ?>

Works perfectly! If anyone has a similar issue, this is how the code should look if you want to hide contact form to non-logged in users:
file: oc-content\themes\modern\inc.search.php

Code:
<div class="has-icon author">                                    
 <?php if( osc_item_user_id() != null && osc_is_web_user_logged_in()  ){ ?>
   <div class="ico-author ico"></div>
        <?php echo osc_item_contact_name(); ?>
<?php } ?>
<div class="mini">
        <?php if( osc_item_show_email() ) { ?>
        <?php echo osc_item_contact_email(); ?>
<?php } ?>
         <?php if ( osc_user_phone(osc_item_user_id()) != '' && osc_is_web_user_logged_in()  ) { ?>
         <?php _e("Tel", 'realestate'); ?>.: <?php echo osc_user_phone() ; ?>
<?php } ?>
</div>

Lines 236