EPrints Technical Mailing List Archive

See the EPrints wiki for instructions on how to join this mailing list and related information.

Message: #09668

< Previous (by date) | Next (by date) > | < Previous (in thread) | Next (in thread) > | Messages - Most Recent First | Threads - Most Recent First

Re: [EP-tech] Limit user create new item

Hi Agung,

I think you can implement a "soft" restriction, which just removes the "New Item" button on the "Manage Deposits" page.  However, this would still allow new items to be created from Import or by using the "New Version" button under an item they has already created.  So you may want to use a similar approach to as below disable those buttons.

Create a file in your local archive called cfg/plugins/EPrints/Plugin/Screen/LocalNewEPrint.pm with the following code:

package EPrints::Plugin::Screen::LocalNewEPrint;

use EPrints::Plugin::Screen::NewEPrint;

our @ISA = qw/ EPrints::Plugin::Screen::NewEPrint /;

sub allow_create
    my ( $self ) = @_;

    my $user = $self->{session}->current_user;

    if ( $user->get_value( 'usertype' ) eq "user" && $user->owned_eprints_list->count >= 2 )
        return 0;

    return $self->allow( "create_eprint" );


The you need to either edit your archive's cfg/cfg.d/plugins.pl or create a new config file under your archive (e.g. cfg/cfg.d/z_restrict_new_items.pl) and add the following two lines:

$c->{plugin_alias_map}->{"Screen::NewEPrint"} = "Screen::LocalNewEPrint";
$c->{plugin_alias_map}->{"Screen::LocalNewEPrint"} = undef;

Run "epadmin test" and then reload you web server and this should prevent users of regular user type from seeing the "New Item" button on their "Manage Deposits" page if they already have two or more items.  If you want to restrict other types of user as well you will need to modify LocalNewEPrint.pm appropriately.


David Newman

On 07/03/2024 04:06, Agung Prasetyo W. wrote:
CAUTION: This e-mail originated outside the University of Southampton.
CAUTION: This e-mail originated outside the University of Southampton.

Is it possible to limit creating new items per user to only 2 times. If there is, please tell me how to do it.

Thank you.

Agung PW

*** Options: https://wiki.eprints.org/w/Eprints-tech_Mailing_List
*** Archive: https://www.eprints.org/tech.php/
*** EPrints community wiki: https://wiki.eprints.org/