3

I there a way to restrict the number of entries by a user to one active entry at a time?

I'd love to create some kind of freemium model for my classifieds site, which only allows for one active ad by any free user.

1
  • Are you trying to restrict in the CP or in Safecracker? – Parscale Nov 29 '12 at 16:57
4

Are you using a SAEF to let people post the classified ad? If so you can use conditionals to check to see if that user has an entry already. Something like:

{exp:channel:entries channel="classified_ads" author_id="CURRENT_USER" dynamic="no"}

{if no_results}
{embed="_forms/.saef_form"}
{/if}

{if count == 1}
You currently have an active classified ad. 
{/if}    

{/exp:channel:entries}

You could also drill down further with conditionals and check for an entry over a specific time period, for example, within the last day:

{if "{entry_date format='%Y%m%d'}" !=  "{current_time format='%Y%m%d'}"}
5
  • Thank you, I was dabbling with stash to get it right, but your solution and Brad's are much easier. :) – tibitabo Nov 29 '12 at 17:05
  • Alright, I still got a little problem: I want to show the SAEF as long as a limit of 3 entries has not been reached, but {count} spits out 1 2 3, while the output of {total_results} loops, like 333, so I can not use {if total_results <= 3}. :( – tibitabo Nov 29 '12 at 17:33
  • OK, it's still not working. Can anybody please chime in? I'm trying to get {total_results <= 3} to work, but the output is 3 3 3, when 3 entries are present. – tibitabo Nov 29 '12 at 18:04
  • have you tried {absolute_count} or {absolute_results} – Mel Nov 29 '12 at 18:30
  • Ah, no... didn't even know they exist. Thanks a lot! :) – tibitabo Nov 30 '12 at 6:37
1

If you are having your members add entries by safecracker this shouldn't be too tough. You would just need to restrict them from publishing to safecracker by how many entries they have.

Just test if you have a valid entry, if not show the form, if so then show a message saying they can only have one entry at a time.

Brad

0

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.