Osclass Support Forums

Osclass theme support => Stela Osclass Theme => Topic started by: epoolroy on April 14, 2018, 05:54:51 AM

Title: How to show User type at Profile?
Post by: epoolroy on April 14, 2018, 05:54:51 AM
Hai, i had one question, how can i do show a user type on profile? For information, i already create 3 user type (User, Company, Enterprise)
What i want just show the user type on user profile.

Example : User Type : Company

I put this code but not work at user-profile.php

Code: [Select]
<div class="row">
              <label for="b_company"><?php _e('User type''stela'); ?></label>
              <?php if( osc_user_type() =="1" ) echo _e('Company','stela');
                if( 
osc_user_type() =="2" ) echo _e('Enterprise','stela'); 
                    else echo 
_e('User','stela'); ?>

            </div>

And this code at hUsers.php

Code: [Select]
   function osc_user_type() {
       return (string) osc_user_field("b_company");
    }
   

Can tell me what im wrong and please help me to fix this code.
Thank you
Title: Re: How to show User type at Profile?
Post by: Dawid on April 14, 2018, 06:52:48 AM
<div class="elem type">
              <?php $user = User::newInstance()->findByPrimaryKey( osc_user_id() ); ?>
              <?php if($user['b_company'] == 1) { ?>
                <i class="fa fa-briefcase"></i> <?php _e('Company', 'stela'); ?>
              <?php } else { ?>
                <i class="fa fa-user-o"></i> <?php _e('Privat person', 'stela'); ?>
              <?php } ?>
            </div>


You can change " privat person" ---> Enterprise .
Title: Re: How to show User type at Profile?
Post by: epoolroy on April 16, 2018, 04:30:35 AM
<div class="elem type">
              <?php $user = User::newInstance()->findByPrimaryKey( osc_user_id() ); ?>
              <?php if($user['b_company'] == 1) { ?>
                <i class="fa fa-briefcase"></i> <?php _e('Company', 'stela'); ?>
              <?php } else { ?>
                <i class="fa fa-user-o"></i> <?php _e('Privat person', 'stela'); ?>
              <?php } ?>
            </div>


You can change " privat person" ---> Enterprise .

Nice code but this not what i mean.... I had 3 user type....
Title: Re: How to show User type at Profile?
Post by: MB Themes on April 16, 2018, 07:52:21 AM
@epoolroy
b_company  --> it means that this field should accept only 2 values: 1, 0 (boolean)
Title: Re: How to show User type at Profile?
Post by: epoolroy on April 16, 2018, 08:06:07 AM
@epoolroy
b_company  --> it means that this field should accept only 2 values: 1, 0 (boolean)

How can i do accept 3 values?
Title: Re: How to show User type at Profile?
Post by: MB Themes on April 16, 2018, 08:52:22 AM
Update database structure
Title: Re: How to show User type at Profile?
Post by: epoolroy on April 16, 2018, 10:06:04 AM
Update database structure
How? can you assist me?
Title: Re: How to show User type at Profile?
Post by: HappyTiger on March 15, 2021, 09:37:00 AM
UserActions.php
find this
Code: [Select]
$input['b_company']      = (Params::getParam('b_company') != '' && Params::getParam('b_company') != 0) ? 1 : 0;replace with this
Code: [Select]
$input['b_company']      = (Params::getParam('b_company') != '') ? Params::getParam('b_company') : null;
Title: Re: How to show User type at Profile?
Post by: MB Themes on March 15, 2021, 09:49:48 AM
@HappyTiger
This is not going to help, until b_company field in t_user table has type tinyint(1), you should change it to int or so first, then you can assign new values into this field.