Advertisement:

Author Topic: Extra fields for user profiles  (Read 1360 times)

anton

  • Newbie
  • *
  • Posts: 11
Extra fields for user profiles
« on: February 26, 2015, 04:02:43 pm »
There's a plugin that adds new fields to item pages. Is there a plugin that does the same for user public profiles?
« Last Edit: March 03, 2015, 02:26:20 pm by anton »

anton

  • Newbie
  • *
  • Posts: 11
Re: Extra fields for user profiles
« Reply #1 on: March 03, 2015, 02:23:37 pm »
So. As I understand, there's no plugin that adds new fields for Public user profiles..
How to implement that without a plugin, manually?

Let's say you need to add a new field – twitter profile url.

1. Create a new column in the table oc_t_user via phpMyAdmin: u_twitter

2. In user-public-profile.php show this field if it's not empty:

Code: [Select]
<?php if(osc_user_field("u_twitter") !== '' ) { ?>
   <li class="website" style="margin-top: 10px;">
     <a href="<?php echo osc_user_field("u_twitter"?>"><?php echo osc_user_field("u_twitter"?></a>
   </li>
<?php ?>

3. To display the field on the 'Update account' page add a new function to user.form.class.php
Code: [Select]
static public function twitter_text($user = null) {
    parent::generic_input_text("u_twitter", isset($user['u_twitter'])? $user['u_twitter'] : '', null, false);
}

and call it in user-profile.php:
Code: [Select]
<div class="control-group">
     <label class="control-label" for="Twitter"><?php _e('Twitter''bender'); ?></label>
            <div class="controls">
                    <?php UserForm::twitter_text(osc_user()); ?>
             </div>
</div>

If you fill this field via phpMyAdmin, osclass displays it well both on the public profile and 'update' page. The question is how to update the DB when user changes the field and click 'Update'

4. ?

« Last Edit: March 03, 2015, 02:58:43 pm by anton »

anton

  • Newbie
  • *
  • Posts: 11
Re: Extra fields for user profiles
« Reply #2 on: March 03, 2015, 02:54:24 pm »
I think i've found the solution:

4. In UserActions.php you need to find the prepareData() function and add this code inside:

Code: [Select]
$input['u_twitter'] = trim(Params::getParam('u_twitter'));
5. In User.php add 'u_twitter' to the:

Code: [Select]
$array_fields = array(
                'pk_i_id',
                'dt_reg_date',
                'dt_mod_date',
                's_name',
                's_password',
                's_secret',
                's_username',
...