Support

Account

Home Forums General Issues Updating field when user clicks on a link

Unread

Updating field when user clicks on a link

  • Hi!

    I am trying to update the field when a user clicks on a certain link. I have this below on an event page:

    <a class="accept-button" href="<?php accept_event(); ?>">Accept</a>
    <a class="reject-button" href="<?php reject_event(); ?>">Reject</a>

    Then this in function.php of my theme:

    function accept_event() {
    	$value = $_POST['Accepted'];
    	update_field('field_53bc53fb91487', $value, $event_id);
    }
    function reject_event() {
    	$value = $_POST['Rejected'];
    	update_field('field_53bc53fb91487', $value, $event_id);
    }

    Basically if a user clicks the accepted link, the function accept_event runs, the field is then changed to the words ‘Accpeted’, and same case with the reject link. However, my problem is that when having update_field whether it is in the function or in the href of the link, it’ll run automatically once that page is loaded. It does not wait for if the link was clicked.

Viewing 1 post (of 1 total)

The topic ‘Updating field when user clicks on a link’ is closed to new replies.