2

How to show the profile completeness progress bar in php WordPress? After registration, I am displaying the whole values in the user profile page. Depending on the data filled in on the edit profile page, I want to show the progress bar on the profile page. Is there any way to do this?

if ($firstname != "") {
    // add some points and show status bar is 2%
}
Kevin M. Mansour
  • 2,915
  • 6
  • 18
  • 35
Naveenbos
  • 2,532
  • 3
  • 34
  • 60
  • what do you mean by 'the' profile completeness progress bar? – Daniël Tulp Feb 05 '14 at 14:22
  • for adding a progress bar, have a look at http://stackoverflow.com/questions/7190898/progress-bar-with-html-and-css/18631308#18631308 – Daniël Tulp Feb 05 '14 at 14:22
  • filling up on the edit profile page need to show the progress bar, like your profile completed 50% please fill the all fields you will get a new privilege like this. – Naveenbos Feb 05 '14 at 14:25
  • @Daniel , But depends up on the value filled in the edit profile page, i need to show the progress bar in the profile page. is that possible with this above link – Naveenbos Feb 05 '14 at 14:27
  • you'll need to add functionality to Wordpress to calculate a percentage of completeness. First try it yourself and post the problems you encounter along the way, then we can help you with that. – Daniël Tulp Feb 05 '14 at 14:36
  • I am stuck. From where i can start? any idea? – Naveenbos Feb 05 '14 at 15:01
  • Here is the answer http://stackoverflow.com/questions/12142690/percent-complete-bar-for-profile-similar-linkedin Thanks Mihai Iorga – Naveenbos Feb 06 '14 at 08:47

2 Answers2

2
$maximumPoints  = 100;
        if ( is_user_logged_in() ) {                 
             if($twitterHandle!=""){
                $hasCompletedTwitterHandle = 10;

             }
             if($linkedinHandle!=""){
                $hasCompletedLinkedinHandle = 10;

             }
             if($googleplusHandle!=""){
                $hasCompletedGoogleplusHandle = 10;

             }
             if($website_url!=""){
                $hasCompletedWebsite_url = 10;

             }

             $percentage = ($hasCompletedTwitterHandle+$hasCompletedLinkedinHandle+$hasCompletedGoogleplusHandle+$hasCompletedWebsite_url)*$maximumPoints/100;
             echo "Your percentage of profile completenes is".$percentage."%";
             echo "<div style='width:100px; background-color:white; height:30px; border:1px solid #000;'>
             <div style='width:".$percentage."px; background-color:red; height:30px;'></div></div>";
        } 

i have did this code now the progress bar is coming. i have an issue with this code, if a user is logged in he can see the other users profile progress bar. i do not need this, how can i restrict that, if a user is logged in that user want to see his progress bar only

Naveenbos
  • 2,532
  • 3
  • 34
  • 60
1

i think css could do the trick....

   <div style="background:red;border:1px solid;">
        <div style="width:<?=$completePercentage?>%;background:green;">
            <?=$completePercentage?>    
        </div>
   </div>

you can calculate value for "$completePercentage" var based on your profile completeness criteria !!

bajajsahil
  • 66
  • 3