Forum

Thread tagged as: Question, Forms, Members

Remove member tag after form submitted

I am looking to create a simple online vote function for members of a site. I plan to display the vote page based on them having a tag "vote" assigned to their member account. I will then use Perch forms for their vote. I would then like to remove the "vote" tag from their member account so they can not vote again. is it possible to use the

<?php perch_member_remove_tag('vote'); ?>

function from a form as it is submitted. I can see that you can add multiple apps to a form but how could I add this function or make it run after the form has been submitted?

Any ideas appreciated

Greg Riley

Greg Riley 1 points

  • 2 years ago

Add <?php perch_member_remove_tag('vote'); ?> to a layout, then add layout to your forms success section of the template.

<perch:success>
  <perch:layout path="remove_vote_tag">
</perch:success>

Brilliant, thanks Robert, I will give it a try and report back.

That seems to work. I have added another bit to log the user out after the tag is removed as tag changes only seem to work once you log in again. so my for success not looks like this:

<perch:success>
    <perch:layout path="remove_vote_tag">
    <div class="alert alert-success">Thanks, your vote has been sent correctly.</div>
    <div class="alert alert-danger">You have also been logged out for voting security. Please login again to continue using this area.</div>
    <perch:layout path="logout">
</perch:success>

with the layout logout.php having:

<?php 

    perch_member_log_out(); 

Thanks again for your help.