*

pitbull

  • **
  • 95 posts
Hi Frosticek. I need to check in the main page of my site if a user has a business profile or not.  Could you please help me.
I want to do something like that:

Code: [Select]
if user has business profile {
//DO SOMETHING HERE

} else {

//DO SOMETHING ELSE

}


In osclass for example you can use
Code: [Select]
if($user["b_company"]==1)
to check if the member is user or company.

*

pitbull

  • **
  • 95 posts
Re: Need some help on how to check if a user has has a business profile or not.
« Reply #1 on: September 19, 2019, 02:27:51 PM »
If what i asked before is difficult is there a way to automatically change the osclass user type from user to company every time the admin validate a business profile ?

For example as it is now when a user applying for business profile and the admin enable/validate this profile to business profile the user type is still "user" for example at the item page under the user info is still displaying "User" instead of company and i have to change that manually in admin page for every user !!!

UPDATE: i tried the helper:
Code: [Select]
if (bpr_is_business()) {
but doesnt work :(
« Last Edit: September 19, 2019, 03:02:57 PM by pitbull »

Marked as best answer by frosticek on September 20, 2019, 03:35:05 PM
*

MB Themes

Re: Need some help on how to check if a user has has a business profile or not.
« Reply #2 on: September 19, 2019, 03:23:05 PM »
@pitbull
Try with user id.
Code: [Select]
if(bpr_is_business(_some_user_id_here_)) { .... }
  To get fast support, we need following details: Detail description, URL to reproduce problem, Screenshots

*

pitbull

  • **
  • 95 posts
Re: Need some help on how to check if a user has has a business profile or not.
« Reply #3 on: September 19, 2019, 03:52:02 PM »
@pitbull
Try with user id.
Code: [Select]
if(bpr_is_business(_some_user_id_here_)) { .... }

That make sense, but doesnt work if you dont know the user id or if you print a list of many users.

So to extend your answer and also help other people here, you can easily get each user id using osclass helper
Code: [Select]
osc_user_id() and pass it inside your helper like that:
Code: [Select]
if(bpr_is_business(osc_user_id())) { //DO SOMETHING HERE }
Absolutely awesome! You can mark this as solved and the best answer as well ;)


« Last Edit: September 19, 2019, 05:18:33 PM by pitbull »