• I like to restrict my WordPress site by paid subscriptions.
    Based on the subscription level, members can certain pages with specific functionality. So far so good, this can be easily done with different plugins.
    But on the restricted pages, members can execute functionality which is basically returning customized content based on their individual input. The functions are implemented via forms and PHP functions.
    Is there a way to implement some kind of counter which limits the amount of function calls by subscription level? e.g. basic members can only call the function 50 times per month?

    • This topic was modified 1 year, 11 months ago by Jan Dembowski.
Viewing 2 replies - 1 through 2 (of 2 total)
  • I would say that it is possible. But how exactly depends on the used subscription plugin and your definition of “Functions”. More than a general answer I can not give without knowing more details.

    Moderator bcworkz

    (@bcworkz)

    Agreed, there’s a way. A common technique is to save counter values in user meta. We’d hook a particular action to increment or decrement the counter value. The action hook involves a caveat that’s not to well documented and catches people by surprise: A single action can sometimes fire more than once per request. This could mean someone’s counter could be decremented more than once for a single request. This would obviously anger users.

    The solution is to have your callback remove itself from the action stack after its first run through, thus avoiding any subsequent firings during the same request.

Viewing 2 replies - 1 through 2 (of 2 total)
  • The topic ‘Paid membership restricted by count of calls’ is closed to new replies.