# wpdirectorykit/1.3.4/custom_user_roles.php

WP Directory Kit, version 1.3.4. 27 lines.

- Page: https://pluginprobe.com/plugins/wpdirectorykit/1.3.4/code/custom_user_roles.php
- Raw: https://pluginprobe.com/plugins/wpdirectorykit/1.3.4/raw/custom_user_roles.php
- Modified: 2024-06-20T21:53:40+00:00

Line numbers below start at 1. Link to a line or a range by appending a fragment to the
page URL, for example `https://pluginprobe.com/plugins/wpdirectorykit/1.3.4/code/custom_user_roles.php#L10-L20`.

```php
<?php

if ( ! defined( 'ABSPATH' ) ) {
	exit; // Exit if accessed directly.
}

add_action( 'init', 'wdk_custom_user_roles' );
function wdk_custom_user_roles()
{
    add_role('wdk_agent'  , __('Agent', 'wpdirectorykit'), array( 'read' => true, 'level_0' => true ) );
    $role = get_role('wdk_agent');
    $role->add_cap('edit_own_listings'); 
    $role->add_cap('edit_own_profile');
    $role->add_cap('upload_files');

    add_role('wdk_listing_admin'  , __('Listing Admin', 'wpdirectorykit'), array( 'read' => true, 'level_0' => true ) );
    $role = get_role('wdk_listing_admin');
    $role->add_cap('edit_own_listings'); 
    $role->add_cap('edit_own_profile');
    $role->add_cap('upload_files');
    $role->add_cap('wdk_listings_manage');

    $role = get_role('administrator');
    $role->add_cap('wdk_listings_manage'); 
}

?>
```
