Search code examples
expressionengine

Expression engine: Maximum number of entries allowed per membrr group


Is it possible to limit the number of channel entries a member can create? I would like to set a max number per member group.

Thanks


Solution

  • Yes, but it would require writing an extension. The logic would be something like this (assuming you're talking about limiting on the back-end ... from the front-end, if you're using a Safecracker entry form for example, you'd need to take a different approach):

    1. use the sessions_end hook
    2. check to make sure you're in the control panel ($this->EE->input->get('D') == 'cp')
    3. check to make sure you're on the publish screen ($this->EE->input->get('C') == 'content_publish')
    4. query the database to see how many entries in exp_channel_titles with the channel_id of $this->EE->input->get('channel_id') belong to $this->EE->session->userdata('member_id')
    5. if the result is greater than your allowed maximum, show them an error

    That should get you started.