Home Forums General Issues Search post for ACF value via form input


Search post for ACF value via form input

  • Hello,

    I’ve a custom post type “downloads” with a custom field “password”.
    The user should be able to type in the password in a front end html form and when there is a match the user should be redirected to the article….
    How could I achive this?

  • The simplest method is to create a form that has a field with a name that does not conflict with any WP reserved words

    <form ....>
      <input name="post_passcode"  .....>

    This is just the basics, of course you should also add a nonce field as well as sanitizing the input.

    add_action('init', 'test_form_passcode');
    function test_form_passcode() {
      if (!isset($_POST['post_passcode'])) {
      // sanitize
      // WP_Query
      // If results, loop, get post permalink
Viewing 2 posts - 1 through 2 (of 2 total)

The topic ‘Search post for ACF value via form input’ is closed to new replies.