Jump to content

[SOLVED] How to allow only superuser access to a programmatically field?


PWaddict
 Share

Recommended Posts

Hello! How can I set access to superuser only to a field that is created programmatically and doesn't belong to any template?

Here is the code of the field that is part of a process module where that field is accessed by a custom page under setup:

$field = $modules->get('InputfieldText');
$field->attr('name', 'myfield');
$field->label = $this->_('My Field');
$field->attr('value', $this->myfield);
$form->add($field);

 

Link to comment
Share on other sites

11 minutes ago, bernhard said:
if(wire()->user->isSuperuser()) {
	// your code
}

?

Unfortunately that way if a site editor edit the custom page and the superuser never edited it before, the default field value from construct method will not get saved. Feel free to check my process module code here.

Link to comment
Share on other sites

  • PWaddict changed the title to [SOLVED] How to allow only superuser access to a programmatically field?

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
 Share

  • Recently Browsing   0 members

    • No registered users viewing this page.
×
×
  • Create New...