1
deka87
Estimate profile completeness
  • 2012/8/16 10:07

  • deka87

  • Friend of XOOPS

  • Posts: 1125

  • Since: 2007/10/5


Hi guys,

I am looking for some elegant way to estimate user profile completeness. Has anybody already tried to implement this? Any ideas?

Deka

2
deka87
Re: Estimate profile completeness
  • 2012/8/17 7:10

  • deka87

  • Friend of XOOPS

  • Posts: 1125

  • Since: 2007/10/5


So I came up with this code :

// ===================== Profile completeness hack =============================== //
$query_c "SELECT * FROM " $xoopsDB -> prefix"profile_profile" ) . " WHERE profile_id = '$uid'";
$result_c $xoopsDB -> query ($query_c );
$all_rows $xoopsDB -> fetchArray$result_c );
$num_rows count$all_rows );
$full_rows array_diff($all_rows,array(NULL));
$num_full_rows count (  $full_rows );
$perc floor($num_full_rows*100/$num_rows). '%';
$xoopsTpl->assign('compl'$perc);
// ==================== End of profile completeness hack ===================================== //


May be useful for somebody...

3
deka87
Re: Estimate profile completeness
  • 2012/8/17 8:00

  • deka87

  • Friend of XOOPS

  • Posts: 1125

  • Since: 2007/10/5


Looks pretty nice, IMO

Resized Image

4
jimmyx
Re: Estimate profile completeness
  • 2012/8/17 13:08

  • jimmyx

  • Quite a regular

  • Posts: 338

  • Since: 2007/7/18


nice deka...

can you show the full code ? how did you made the background color for the percent ?

5
deka87
Re: Estimate profile completeness
  • 2012/8/17 14:04

  • deka87

  • Friend of XOOPS

  • Posts: 1125

  • Since: 2007/10/5


jimmyx,

below is the full code :

// ===================== Profile completeness hack =============================== //
$uid $thisUser->getVar('uid');
$query_c "SELECT * FROM " $xoopsDB -> prefix"profile_profile" ) . " WHERE profile_id = '$uid'";
$result_c $xoopsDB -> query ($query_c );

$all_rows $xoopsDB -> fetchArray$result_c );
$num_rows count$all_rows );

$full_rows array_diff($all_rows,array(NULL));
$num_full_rows count (  $full_rows );

$perc floor($num_full_rows*100/$num_rows);
$xoopsTpl->assign('compl'$perc);
// Colors
if ( $perc 25 ) {
    
$class 'warning';
} elseif ( 
$perc >= 25 && $perc 50 ) {
    
$class 'danger';
} elseif ( 
$perc >= 50 && $perc 75 ) {
    
$class 'info';
} else {
    
$class 'success';
}
$xoopsTpl->assign('class'$class);
// ==================== End of profile completeness hack ===================================== //


where warning, info, success, and danger are my css classes for the progress bar. You must put this code in userinfo.php before the
include dirname(__FILE__) . DIRECTORY_SEPARATOR 'footer.php';
?>


Deka

6
irmtfan
Re: Estimate profile completeness
  • 2012/8/21 6:13

  • irmtfan

  • Module Developer

  • Posts: 3419

  • Since: 2003/12/7


very nice code deka87
i will test this hack tomorrow.

7
mjoel
Re: Estimate profile completeness
  • 2021/5/15 13:55

  • mjoel

  • Quite a regular

  • Posts: 325

  • Since: 2006/12/9


i would like to try this where do we exactly put this code ?
is it still working?, im using xoops 2.5.10 and php 7.3

i tried putting it in php block but i got
Error : Error: Call to a member function getVar() on null

Login

Who's Online

291 user(s) are online (165 user(s) are browsing Support Forums)


Members: 0


Guests: 291


more...

Donat-O-Meter

Stats
Goal: $100.00
Due Date: Nov 30
Gross Amount: $0.00
Net Balance: $0.00
Left to go: $100.00
Make donations with PayPal!

Latest GitHub Commits