How to Simply Remove a Specific User_ID from Outputted List










0















I'm trying to display a "Top 10 Leaderboard" list of users on my Wordpress website who have earned the most points using the popular MyCred plugin. The code I found is working perfectly, however against my wishes, myself as the admin always makes the top of this points list because I am on the website helping people all the time, therefore earning points. But, I don't want to be competitive with other users as admin.



New to PHP, I'm having problems figuring out what I need to add to have it not include me — using my Wordpress user ID (#1) I assume — when it generates the "top 10" list.



Here's the complete code I'm working with that I found on GitHub, but I think the relevant small section of code I need to slightly modify is right here:



// Construct unorganized list for each row
echo '<ul class="mycred-this-weeks-leaderboard">';
foreach ($leaderboard as $position => $data)
echo '<li>';
$user_info = get_userdata($data->user_id);
$tempname = $user_info->user_login;
$lowerstring = strtolower($tempname);
$stringwithoutspace = strtr($lowerstring, ' ', '-');
$username = preg_replace('/[^a-zA-Z0-9_]/', '-', $stringwithoutspace);

?>
<?php if (!empty($username)) ?>
<div class="leaderboard-info-block">
<span class="leaderboard-avatar"><?php echo $avatar = get_avatar($data->user_id, 49); ?></span> <span class="leaderboard-profile-link"><a href="<?php echo 'http://chillopedia.com/forums/users/' . $username; ?>"><?php echo $data->display_name; ?></a></span> <br>
<span class="leaderboard-user-points"><?php echo $mycred->format_creds($data->total); ?></span>
</div>
<?php

echo '</li><br>';

echo '</ul>';


Thank you for any help you can give me! :-)










share|improve this question


























    0















    I'm trying to display a "Top 10 Leaderboard" list of users on my Wordpress website who have earned the most points using the popular MyCred plugin. The code I found is working perfectly, however against my wishes, myself as the admin always makes the top of this points list because I am on the website helping people all the time, therefore earning points. But, I don't want to be competitive with other users as admin.



    New to PHP, I'm having problems figuring out what I need to add to have it not include me — using my Wordpress user ID (#1) I assume — when it generates the "top 10" list.



    Here's the complete code I'm working with that I found on GitHub, but I think the relevant small section of code I need to slightly modify is right here:



    // Construct unorganized list for each row
    echo '<ul class="mycred-this-weeks-leaderboard">';
    foreach ($leaderboard as $position => $data)
    echo '<li>';
    $user_info = get_userdata($data->user_id);
    $tempname = $user_info->user_login;
    $lowerstring = strtolower($tempname);
    $stringwithoutspace = strtr($lowerstring, ' ', '-');
    $username = preg_replace('/[^a-zA-Z0-9_]/', '-', $stringwithoutspace);

    ?>
    <?php if (!empty($username)) ?>
    <div class="leaderboard-info-block">
    <span class="leaderboard-avatar"><?php echo $avatar = get_avatar($data->user_id, 49); ?></span> <span class="leaderboard-profile-link"><a href="<?php echo 'http://chillopedia.com/forums/users/' . $username; ?>"><?php echo $data->display_name; ?></a></span> <br>
    <span class="leaderboard-user-points"><?php echo $mycred->format_creds($data->total); ?></span>
    </div>
    <?php

    echo '</li><br>';

    echo '</ul>';


    Thank you for any help you can give me! :-)










    share|improve this question
























      0












      0








      0








      I'm trying to display a "Top 10 Leaderboard" list of users on my Wordpress website who have earned the most points using the popular MyCred plugin. The code I found is working perfectly, however against my wishes, myself as the admin always makes the top of this points list because I am on the website helping people all the time, therefore earning points. But, I don't want to be competitive with other users as admin.



      New to PHP, I'm having problems figuring out what I need to add to have it not include me — using my Wordpress user ID (#1) I assume — when it generates the "top 10" list.



      Here's the complete code I'm working with that I found on GitHub, but I think the relevant small section of code I need to slightly modify is right here:



      // Construct unorganized list for each row
      echo '<ul class="mycred-this-weeks-leaderboard">';
      foreach ($leaderboard as $position => $data)
      echo '<li>';
      $user_info = get_userdata($data->user_id);
      $tempname = $user_info->user_login;
      $lowerstring = strtolower($tempname);
      $stringwithoutspace = strtr($lowerstring, ' ', '-');
      $username = preg_replace('/[^a-zA-Z0-9_]/', '-', $stringwithoutspace);

      ?>
      <?php if (!empty($username)) ?>
      <div class="leaderboard-info-block">
      <span class="leaderboard-avatar"><?php echo $avatar = get_avatar($data->user_id, 49); ?></span> <span class="leaderboard-profile-link"><a href="<?php echo 'http://chillopedia.com/forums/users/' . $username; ?>"><?php echo $data->display_name; ?></a></span> <br>
      <span class="leaderboard-user-points"><?php echo $mycred->format_creds($data->total); ?></span>
      </div>
      <?php

      echo '</li><br>';

      echo '</ul>';


      Thank you for any help you can give me! :-)










      share|improve this question














      I'm trying to display a "Top 10 Leaderboard" list of users on my Wordpress website who have earned the most points using the popular MyCred plugin. The code I found is working perfectly, however against my wishes, myself as the admin always makes the top of this points list because I am on the website helping people all the time, therefore earning points. But, I don't want to be competitive with other users as admin.



      New to PHP, I'm having problems figuring out what I need to add to have it not include me — using my Wordpress user ID (#1) I assume — when it generates the "top 10" list.



      Here's the complete code I'm working with that I found on GitHub, but I think the relevant small section of code I need to slightly modify is right here:



      // Construct unorganized list for each row
      echo '<ul class="mycred-this-weeks-leaderboard">';
      foreach ($leaderboard as $position => $data)
      echo '<li>';
      $user_info = get_userdata($data->user_id);
      $tempname = $user_info->user_login;
      $lowerstring = strtolower($tempname);
      $stringwithoutspace = strtr($lowerstring, ' ', '-');
      $username = preg_replace('/[^a-zA-Z0-9_]/', '-', $stringwithoutspace);

      ?>
      <?php if (!empty($username)) ?>
      <div class="leaderboard-info-block">
      <span class="leaderboard-avatar"><?php echo $avatar = get_avatar($data->user_id, 49); ?></span> <span class="leaderboard-profile-link"><a href="<?php echo 'http://chillopedia.com/forums/users/' . $username; ?>"><?php echo $data->display_name; ?></a></span> <br>
      <span class="leaderboard-user-points"><?php echo $mycred->format_creds($data->total); ?></span>
      </div>
      <?php

      echo '</li><br>';

      echo '</ul>';


      Thank you for any help you can give me! :-)







      wordpress






      share|improve this question













      share|improve this question











      share|improve this question




      share|improve this question










      asked Nov 14 '18 at 2:35









      Curtis B.Curtis B.

      32




      32






















          1 Answer
          1






          active

          oldest

          votes


















          0














          Just skip the code inside loop if the $data->user_id is 1 (your user ID)



          if($data->user_id == 1)
          continue;



          To implement that code to yours:



          echo '<ul class="mycred-this-weeks-leaderboard">';
          foreach ($leaderboard as $position => $data)
          if($data->user_id == 1)
          continue;

          echo '<li>';
          $user_info = get_userdata($data->user_id);
          $tempname = $user_info->user_login;
          $lowerstring = strtolower($tempname);
          $stringwithoutspace = strtr($lowerstring, ' ', '-');
          $username = preg_replace('/[^a-zA-Z0-9_]/', '-', $stringwithoutspace);

          ?>
          <?php if (!empty($username)) ?>
          <div class="leaderboard-info-block">
          <span class="leaderboard-avatar"><?php echo $avatar = get_avatar($data->user_id, 49); ?></span> <span class="leaderboard-profile-link"><a href="<?php echo 'http://chillopedia.com/forums/users/' . $username; ?>"><?php echo $data->display_name; ?></a></span> <br>
          <span class="leaderboard-user-points"><?php echo $mycred->format_creds($data->total); ?></span>
          </div>
          <?php

          echo '</li>';

          echo '</ul>';





          share|improve this answer























          • Thank you SO much Zunan!!! It worked perfectly! I appreciate your time, knowledge, and very clear and precise instructions for me. Makes me want to learn PHP even more now. :-)

            – Curtis B.
            Nov 14 '18 at 17:06











          • You're welcome :)

            – Zunan
            Nov 15 '18 at 6:25










          Your Answer






          StackExchange.ifUsing("editor", function ()
          StackExchange.using("externalEditor", function ()
          StackExchange.using("snippets", function ()
          StackExchange.snippets.init();
          );
          );
          , "code-snippets");

          StackExchange.ready(function()
          var channelOptions =
          tags: "".split(" "),
          id: "1"
          ;
          initTagRenderer("".split(" "), "".split(" "), channelOptions);

          StackExchange.using("externalEditor", function()
          // Have to fire editor after snippets, if snippets enabled
          if (StackExchange.settings.snippets.snippetsEnabled)
          StackExchange.using("snippets", function()
          createEditor();
          );

          else
          createEditor();

          );

          function createEditor()
          StackExchange.prepareEditor(
          heartbeatType: 'answer',
          autoActivateHeartbeat: false,
          convertImagesToLinks: true,
          noModals: true,
          showLowRepImageUploadWarning: true,
          reputationToPostImages: 10,
          bindNavPrevention: true,
          postfix: "",
          imageUploader:
          brandingHtml: "Powered by u003ca class="icon-imgur-white" href="https://imgur.com/"u003eu003c/au003e",
          contentPolicyHtml: "User contributions licensed under u003ca href="https://creativecommons.org/licenses/by-sa/3.0/"u003ecc by-sa 3.0 with attribution requiredu003c/au003e u003ca href="https://stackoverflow.com/legal/content-policy"u003e(content policy)u003c/au003e",
          allowUrls: true
          ,
          onDemand: true,
          discardSelector: ".discard-answer"
          ,immediatelyShowMarkdownHelp:true
          );



          );













          draft saved

          draft discarded


















          StackExchange.ready(
          function ()
          StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fstackoverflow.com%2fquestions%2f53292396%2fhow-to-simply-remove-a-specific-user-id-from-outputted-list%23new-answer', 'question_page');

          );

          Post as a guest















          Required, but never shown

























          1 Answer
          1






          active

          oldest

          votes








          1 Answer
          1






          active

          oldest

          votes









          active

          oldest

          votes






          active

          oldest

          votes









          0














          Just skip the code inside loop if the $data->user_id is 1 (your user ID)



          if($data->user_id == 1)
          continue;



          To implement that code to yours:



          echo '<ul class="mycred-this-weeks-leaderboard">';
          foreach ($leaderboard as $position => $data)
          if($data->user_id == 1)
          continue;

          echo '<li>';
          $user_info = get_userdata($data->user_id);
          $tempname = $user_info->user_login;
          $lowerstring = strtolower($tempname);
          $stringwithoutspace = strtr($lowerstring, ' ', '-');
          $username = preg_replace('/[^a-zA-Z0-9_]/', '-', $stringwithoutspace);

          ?>
          <?php if (!empty($username)) ?>
          <div class="leaderboard-info-block">
          <span class="leaderboard-avatar"><?php echo $avatar = get_avatar($data->user_id, 49); ?></span> <span class="leaderboard-profile-link"><a href="<?php echo 'http://chillopedia.com/forums/users/' . $username; ?>"><?php echo $data->display_name; ?></a></span> <br>
          <span class="leaderboard-user-points"><?php echo $mycred->format_creds($data->total); ?></span>
          </div>
          <?php

          echo '</li>';

          echo '</ul>';





          share|improve this answer























          • Thank you SO much Zunan!!! It worked perfectly! I appreciate your time, knowledge, and very clear and precise instructions for me. Makes me want to learn PHP even more now. :-)

            – Curtis B.
            Nov 14 '18 at 17:06











          • You're welcome :)

            – Zunan
            Nov 15 '18 at 6:25















          0














          Just skip the code inside loop if the $data->user_id is 1 (your user ID)



          if($data->user_id == 1)
          continue;



          To implement that code to yours:



          echo '<ul class="mycred-this-weeks-leaderboard">';
          foreach ($leaderboard as $position => $data)
          if($data->user_id == 1)
          continue;

          echo '<li>';
          $user_info = get_userdata($data->user_id);
          $tempname = $user_info->user_login;
          $lowerstring = strtolower($tempname);
          $stringwithoutspace = strtr($lowerstring, ' ', '-');
          $username = preg_replace('/[^a-zA-Z0-9_]/', '-', $stringwithoutspace);

          ?>
          <?php if (!empty($username)) ?>
          <div class="leaderboard-info-block">
          <span class="leaderboard-avatar"><?php echo $avatar = get_avatar($data->user_id, 49); ?></span> <span class="leaderboard-profile-link"><a href="<?php echo 'http://chillopedia.com/forums/users/' . $username; ?>"><?php echo $data->display_name; ?></a></span> <br>
          <span class="leaderboard-user-points"><?php echo $mycred->format_creds($data->total); ?></span>
          </div>
          <?php

          echo '</li>';

          echo '</ul>';





          share|improve this answer























          • Thank you SO much Zunan!!! It worked perfectly! I appreciate your time, knowledge, and very clear and precise instructions for me. Makes me want to learn PHP even more now. :-)

            – Curtis B.
            Nov 14 '18 at 17:06











          • You're welcome :)

            – Zunan
            Nov 15 '18 at 6:25













          0












          0








          0







          Just skip the code inside loop if the $data->user_id is 1 (your user ID)



          if($data->user_id == 1)
          continue;



          To implement that code to yours:



          echo '<ul class="mycred-this-weeks-leaderboard">';
          foreach ($leaderboard as $position => $data)
          if($data->user_id == 1)
          continue;

          echo '<li>';
          $user_info = get_userdata($data->user_id);
          $tempname = $user_info->user_login;
          $lowerstring = strtolower($tempname);
          $stringwithoutspace = strtr($lowerstring, ' ', '-');
          $username = preg_replace('/[^a-zA-Z0-9_]/', '-', $stringwithoutspace);

          ?>
          <?php if (!empty($username)) ?>
          <div class="leaderboard-info-block">
          <span class="leaderboard-avatar"><?php echo $avatar = get_avatar($data->user_id, 49); ?></span> <span class="leaderboard-profile-link"><a href="<?php echo 'http://chillopedia.com/forums/users/' . $username; ?>"><?php echo $data->display_name; ?></a></span> <br>
          <span class="leaderboard-user-points"><?php echo $mycred->format_creds($data->total); ?></span>
          </div>
          <?php

          echo '</li>';

          echo '</ul>';





          share|improve this answer













          Just skip the code inside loop if the $data->user_id is 1 (your user ID)



          if($data->user_id == 1)
          continue;



          To implement that code to yours:



          echo '<ul class="mycred-this-weeks-leaderboard">';
          foreach ($leaderboard as $position => $data)
          if($data->user_id == 1)
          continue;

          echo '<li>';
          $user_info = get_userdata($data->user_id);
          $tempname = $user_info->user_login;
          $lowerstring = strtolower($tempname);
          $stringwithoutspace = strtr($lowerstring, ' ', '-');
          $username = preg_replace('/[^a-zA-Z0-9_]/', '-', $stringwithoutspace);

          ?>
          <?php if (!empty($username)) ?>
          <div class="leaderboard-info-block">
          <span class="leaderboard-avatar"><?php echo $avatar = get_avatar($data->user_id, 49); ?></span> <span class="leaderboard-profile-link"><a href="<?php echo 'http://chillopedia.com/forums/users/' . $username; ?>"><?php echo $data->display_name; ?></a></span> <br>
          <span class="leaderboard-user-points"><?php echo $mycred->format_creds($data->total); ?></span>
          </div>
          <?php

          echo '</li>';

          echo '</ul>';






          share|improve this answer












          share|improve this answer



          share|improve this answer










          answered Nov 14 '18 at 4:04









          ZunanZunan

          13015




          13015












          • Thank you SO much Zunan!!! It worked perfectly! I appreciate your time, knowledge, and very clear and precise instructions for me. Makes me want to learn PHP even more now. :-)

            – Curtis B.
            Nov 14 '18 at 17:06











          • You're welcome :)

            – Zunan
            Nov 15 '18 at 6:25

















          • Thank you SO much Zunan!!! It worked perfectly! I appreciate your time, knowledge, and very clear and precise instructions for me. Makes me want to learn PHP even more now. :-)

            – Curtis B.
            Nov 14 '18 at 17:06











          • You're welcome :)

            – Zunan
            Nov 15 '18 at 6:25
















          Thank you SO much Zunan!!! It worked perfectly! I appreciate your time, knowledge, and very clear and precise instructions for me. Makes me want to learn PHP even more now. :-)

          – Curtis B.
          Nov 14 '18 at 17:06





          Thank you SO much Zunan!!! It worked perfectly! I appreciate your time, knowledge, and very clear and precise instructions for me. Makes me want to learn PHP even more now. :-)

          – Curtis B.
          Nov 14 '18 at 17:06













          You're welcome :)

          – Zunan
          Nov 15 '18 at 6:25





          You're welcome :)

          – Zunan
          Nov 15 '18 at 6:25

















          draft saved

          draft discarded
















































          Thanks for contributing an answer to Stack Overflow!


          • Please be sure to answer the question. Provide details and share your research!

          But avoid


          • Asking for help, clarification, or responding to other answers.

          • Making statements based on opinion; back them up with references or personal experience.

          To learn more, see our tips on writing great answers.




          draft saved


          draft discarded














          StackExchange.ready(
          function ()
          StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fstackoverflow.com%2fquestions%2f53292396%2fhow-to-simply-remove-a-specific-user-id-from-outputted-list%23new-answer', 'question_page');

          );

          Post as a guest















          Required, but never shown





















































          Required, but never shown














          Required, but never shown












          Required, but never shown







          Required, but never shown

































          Required, but never shown














          Required, but never shown












          Required, but never shown







          Required, but never shown







          這個網誌中的熱門文章

          How to read a connectionString WITH PROVIDER in .NET Core?

          In R, how to develop a multiplot heatmap.2 figure showing key labels successfully

          Museum of Modern and Contemporary Art of Trento and Rovereto