title: How to write if statement on button click
body: <p>Welcome!I would like to create a function in WordPress, which by pressing the check button the user is logged in or not. If a user is logged in, it moves to the &quot;a&quot;, but if the user is offline, moves to the &quot;b&quot;.</p>
  <p>I have trouble implementing the function else if in the button.</p>
  <p>Ruler code button in the cart.php file:</p>
  <pre><code>&lt;a href=&quot;#&quot;&gt; class=&quot;button&quot; CHECK OUT &lt;/a&gt;
  </code></pre>
  <p>The code that checks whether the user is logged in:</p>
  <pre><code>if (is_user_logged_in () &amp;&amp; isset ($ _ GET [ 'page_id']) &amp;&amp; $ _ GET [ 'page_id']&gt; 0 &amp;&amp; get_option ('permalink_structure') == &quot;&quot; &amp;&amp; $ _ GET [ 'page_id'] == woocommerce_get_page_id (' shop ')) {
       wp_redirect (get_post_type_archive_link ('product'));
       die ();
  }
  </code></pre>
  <p>I have tried various options, but all failed.</p>
  <p>Sample:
  1.Click button -&gt;
  a. If a user is logged on - redirect to &quot;http://a&quot;,
  b. If user is logged out - redirect to &quot;hhtp://b&quot;.</p>