This topic contains a post which is marked as Best Answer. Press here if you would like to see it.
Businesses create ads
« on: July 06, 2023, 03:30:53 PM »
I have a question, how could you manage that only companies can place an ad but no normal users? I need your help there.

I would have thought of something like that, but it doesn't work, the page then has an error 500.

Code: [Select]
<?php if(osc_user_is_company()) { ?>
Maybe, you have an idea.

Best regards
Roberto

*

MB Themes

Re: Businesses create ads
« Reply #1 on: July 06, 2023, 06:29:51 PM »
Get logged user record and use b_company key
  To get fast support, we need following details: Detail description, URL to reproduce problem, Screenshots

Re: Businesses create ads
« Reply #2 on: July 06, 2023, 07:22:33 PM »
And how do I then build one in the header?

Marked as best answer by frosticek on July 06, 2023, 08:25:39 PM
Re: Businesses create ads
« Reply #3 on: July 06, 2023, 07:58:38 PM »
So I did it like this in the header, I hope it should work.

Code: [Select]
<?php $seller User::newInstance()->findByPrimaryKey(osc_logged_user_id());
if (
$seller['b_company'] == '1') if( osc_users_enabled() || ( !osc_users_enabled() && !osc_reg_user_post() )) { ?>

          <a class="publish isTablet isDesktop" href="<?php echo osc_item_post_url_in_category() ; ?>"><?php _e("Publish Ad"'sigma');?></a>
        <?php ?>

installed the code.

Code: [Select]
$seller = User::newInstance()->findByPrimaryKey(osc_logged_user_id());
if ($seller['b_company'] == '1')

It might also be of interest to others.




*

MB Themes

Re: Businesses create ads
« Reply #4 on: July 06, 2023, 08:25:33 PM »
Yes.
In latest version osclass there is also osc_logged_user() function that also returns row.
  To get fast support, we need following details: Detail description, URL to reproduce problem, Screenshots