*

StefanGr

  • ***
  • 51 posts
User groups - Display user package
« on: January 18, 2022, 10:17:52 PM »
Since I'm not a programmer I would like to share with the community my workaround of showing  user type in public profile, after he purchased a package, and ask if this is OK from programmer point of view.

Quote

Quote
   <?php
            $test_gr = osp_get_user_group(osc_user_id());
         
   ?>

<?php
if ($test_gr == 1) {  ?>

   <div><img src="path_to_image/utilizator_silver.png" style="vertical-align: middle;width:50px;height:50px;" /> <a href="" style="text-decoration:none"><span style="vertical-align: middle;"><?php echo "Utilizator Silver"; ?> </a></span> </div>

<?php
} elseif ($test_gr == 2) {
?>
   <div><img src="path_to_image/utilizator_gold.png" style="vertical-align: middle;width:50px;height:50px;" /> <a href="" style="text-decoration:none"><span style="vertical-align: middle;color:#d7c100">  <?php echo "Utilizator Gold"; ?> </a></span> </div>

<?php
} elseif ($test_gr == 3) {
?>
   <div><img src="path_to_image/utilizator_platina.png" style="vertical-align: middle;width:50px;height:50px;" /> <a href="" style="text-decoration:none"><span style="vertical-align: middle;color:#5c00ff">
   <?php echo "Utilizator Platinum"; ?> </a></span> </div>

<?php
}  else

{
?>
   <?php echo " " ?>

<?php
   
}
?>

This would be a nice feature in future updates.

On the other hand, totally unrelated , can this be adapted to make a "Verified User" using phone login / phone verification plugin ( or 2fa phone or how is called ?)
;) nothing here, move on.

Marked as best answer by StefanGr on January 21, 2022, 08:38:06 AM
*

MB Themes

Re: User groups - Display user package
« Reply #1 on: January 19, 2022, 01:37:02 PM »
@StefanGr
Functional, but I would say wrong :)

Code: [Select]
<?php
  $group 
ModelOSP::newInstance()->getUserGroupRecord(osc_logged_user_id());
?>


<?php if(@$group['pk_i_id'] > 0) { ?>
  <div>
    <img src="<?php echo osc_base_url(); ?>path-to-group-icons/<?php echo $group['pk_i_id']; ?>.png" alt="User membership"/>
    <a href=""><?php echo $group['s_name']; ?></a>
  </div>
<?php ?>
  To get fast support, we need following details: Detail description, URL to reproduce problem, Screenshots

*

StefanGr

  • ***
  • 51 posts
Re: User groups - Display user package
« Reply #2 on: January 19, 2022, 05:03:26 PM »
@StefanGr
Functional, but I would say wrong :)

Code: [Select]
<?php
  $group 
ModelOSP::newInstance()->getUserGroupRecord(osc_logged_user_id());
?>


<?php if(@$group['pk_i_id'] > 0) { ?>
  <div>
    <img src="<?php echo osc_base_url(); ?>path-to-group-icons/<?php echo $group['pk_i_id']; ?>.png" alt="User membership"/>
    <a href=""><?php echo $group['s_name']; ?></a>
  </div>
<?php ?>

Correct me if im wrong. But, if you call for logged_user_id, dosen't mean that it will only work for the logged person and would not work if used in public profile ? F.E me as logged user , i want to see the X user profile, with his membership status.

__
 ::) indeed , cleaner,more stylish and beyond my basic knowledge of programming
;) nothing here, move on.

*

MB Themes

Re: User groups - Display user package
« Reply #3 on: January 19, 2022, 09:32:29 PM »
Yes correct, I was not reading where you use it.
osc_user_id() should work there  ;)
  To get fast support, we need following details: Detail description, URL to reproduce problem, Screenshots

*

Tango

  • ****
  • 214 posts
Re: User groups - Display user package
« Reply #4 on: January 21, 2022, 12:31:12 AM »
Actually this is a pretty nice idea, and coupled with the future enhanced user groups, would make it a great addition.

I would add it as a function to the plugin core and make a note for it in the Groups description, that you can manually hook it to the theme, anywhere you want the user group name to appear.

For example, if you create the hidden group Sellers and add a user as a member of that group, you can hook the function to the User Public Profile, so everyone would know that the user is an authorized Seller. 8)
Sweet!