Skip to content

Instantly share code, notes, and snippets.

@faisalahammad
Last active June 27, 2024 16:28
Show Gist options
  • Select an option

  • Save faisalahammad/68687ddd3c1ef8a7b5630d59f439ec69 to your computer and use it in GitHub Desktop.

Select an option

Save faisalahammad/68687ddd3c1ef8a7b5630d59f439ec69 to your computer and use it in GitHub Desktop.

First add a custom CSS class (attend_event) on the radio button "Field Settings → Appearance → Custom CSS Class" like the following screenshot.

custom class

Now add the following jQuery code to the child theme or use the Simple Custom CSS and JS plugin. Now go to the "Custom CSS & JS → Add Custom JS" and add the code like the following screenshot.

jQuery(document).ready(function ($) {
    $(".attend_event input.gfield-choice-input[value='No']").click(function () {
      if ($(this).is(":checked")) {
        window.location.href = "https://example.com";
      }
    });
});

custom javascript

If you check, you'll see the users redirect to the example.com whenever they select the "No" option from the radio button.

Preview

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment