title: How do do_action and add_action work?
body: <p>I am trying to find what exactly do_action and add_action works. I already examine with add_action but for do_action i am trying as new now. This what i tried.</p>
  
  <pre><code>function mainplugin_test() {
  
  $regularprice = 50;
  
  if(class_exists('rs_dynamic')) {
  $regularprice = 100;
  }
  
  // and doing further
  //like i echoing the regular price
  echo $regularprice; //It print 100 from this code
  
  }
  </code></pre>
  
  <p>Now instead of placing few code in main file i am planning to create do_action to avoid code messing issue. </p>
  
  <pre><code>    function mainplugin_test() {
  
      $regularprice = 50;
  
      do_action('testinghook');
  
  // and doing further
  //like i echoing the regular price
  echo $regularprice; //It should print 100 but it print 50
  
      }
  </code></pre>
  
  <p>so i created another function to point out that hook as something like</p>
  
  <pre><code>function anothertest() {
  if(class_exists('rs_dynamic')) {
  $regularprice = 100;
  }
  }
  add_action('testinghook','anothertest');
  </code></pre>
  
  <p>Not sure how to add the lines of code to that hook that above function may work? As per i tried in my testing environment nothing helps. If i understand correct do_action is more like including a file??? If not please advise me.</p>
  
  <p>Thanks.</p>