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.

 

Enable Notifications OK No thanks

We use cookies - more information

Multimusen.dk will set a few cookies from Doubleclick, Google and the Social Media plugins they ay set some cookies. Some of my pages use APIs - such as YouTube, LinkedIn, Google Fonts, Google Maps, Mapbox, Spotify, Jetpack, Twitter, Facebook &c.. Such plugins may set the odd cookie.

Close