How to implement a button with different redirections?
Point the button to a custom controller:

namespace Drupal\mymodule\Controller;

use Drupal\Core\Controller\ControllerBase;

class ExampleController extends ControllerBase {

  /**
   * Controller for action button.
   */
  public function action() {

    // if user is not logged in, redirect to create a new account
    if ($this-&gt;currentUser()-&gt;isAnonymous()) {
      return $this-&gt;redirect('user.register');
    }

    // else return content or redirect to content
    return ...;
  }

}