Categories
Kanban WordPress

Adgangskontrol i WP

Denne lille stump kode er meget nyttig:

if ( !current_user_can( 'publish_posts' ) )  {
		wp_die( __( 'You do not have sufficient permissions to access this page.' ) );
	}

Her er WP listen over brugerrettigheder: user_can “Roles and Capabilities” på Codex.

En række af WPs hooks skriver “capability”. Hvis fx en Contributor skal have adgang til noget, så kan capability være edit_posts. Enkelt og praktisk.

 

By Per Thykjaer Jensen

Per is the WordPress expert at Business Academy Aarhus. Senior Lecturer at the Multimedia Design Programme. His background is in the Arts: MA Literature History and BA Art History. Later he added a MA in IT, interaction and Multimedia. And he is a wicked Linux user.