PHP code example of adamkiss / kirby-impersonate

1. Go to this page and download the library: Download adamkiss/kirby-impersonate library. Choose the download type require.

2. Extract the ZIP file and open the index.php.

3. Add this code to the index.php.
    
        
<?php
require_once('vendor/autoload.php');

/* Start to develop here. Best regards https://php-download.com/ */

    

adamkiss / kirby-impersonate example snippets


<?= kirby()->user()->isImpersonated() ? '<a href="/__impersonate/stop">Stop Impersonation</a>' : ''

// config.php
return [
	'adamkiss.kirby-impersonate' => [
		'can-impersonate' => function () {
			// who can impersonate? this is a user method,
			// so "$this" is a user who's checked.
			// you have access to role, email, uuid…

			/** @var User $this */
			return true;
		},
		'can-be-impersonated' => function () {
			// who can be target of impersonation? this is a user method,
			// so "$this" is a user who's checked
			// you have access to role, email, uuid…

			/** @var User $this */
			return true;
		},
		
		// Since the start of redirection is in the users area, null just reloads
		// You can also use a string to get a URL, or a Closure with the impersonated user
		// if you need different redirects base on role / email / whatever
		'redirect-after-impersonation-start' => null,

		// Where you're redirected after the impersonation stops
		// this can be only a string
		'redirect-after-impersonation-stop' => kirby()->url('panel') . '/users',    ]
];