This helpful but of code adds an edit link to a page using the ProcessWire platform. Add this to generate the link:
if (wire('page')->editable() === true) {
echo '<a href="' . wire('page')->editUrl . '">Edit page</a>';
}
The editable()
function handles all the checking of permissions so the user must:
- Be logged in
- Have the correct permissions
