It took me a while to figure out how to limit members ability to publish only one channel entry so I thought I would share. I received some help along the way. I hope this helps someone else.
You’ll need two templates. This is because you can’t have one channel entries tag inside another.
1. The first is your “publish” template with your own Safecracker code (see Safecracker wiki).
2. The second is a simple “route” template that only has the following code in it.
publish template sample code
{if logged_out}{redirect="login"}{/if}
{exp:channel:entries channel="myChannelName" author_id="CURRENT_USER" status="pending|open"}
{if count == 1}{if total_results >= 1}{redirect="profiles/route"}{/if}{/if}
{/exp:channel:entries}
{exp:safecracker channel="myChannelName" return="profiles/edit/ENTRY_ID" entry_id="{segment_3}" error_handling="inline"}
...route template
{exp:channel:entries channel="myChannelName" author_id="CURRENT_USER" limit="1" sort="asc" status="pending|open"}
{redirect="profiles/edit/{entry_id}"}
{/exp:channel:entries}publish template code explained
- the if conditional redirects anyone who happens to visit the url that isn’t logged in first (not needed)
- the first entries tag pair checks the current logged in users entries to see if they already created one or not
if they’ve already published an entry they get redirected to the “route” template
- this keeps members from publishing more than one entry
route template code explained
- get the “entry id” of the members first entry and redirect them to the “edit” safecracker template
- side note, adding a custom status of pending to your channel will allow you to include both pending and open entries
so that members can edit entries that an admin hasn’t moved to open status yet