Osclass Support Forums

Osclass plugin support => Business Profile Plugin => Topic started by: pitbull on September 18, 2019, 05:43:10 PM

Title: Need some help on how to check if a user has has a business profile or not.
Post by: pitbull on September 18, 2019, 05:43:10 PM
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.
Title: Re: Need some help on how to check if a user has has a business profile or not.
Post by: pitbull 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 :(
Title: Re: Need some help on how to check if a user has has a business profile or not.
Post by: MB Themes on September 19, 2019, 03:23:05 PM
@pitbull
Try with user id.
Code: [Select]
if(bpr_is_business(_some_user_id_here_)) { .... }
Title: Re: Need some help on how to check if a user has has a business profile or not.
Post by: pitbull 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 ;)