PHP code example of freshsystems / wp-permission-manager

1. Go to this page and download the library: Download freshsystems/wp-permission-manager 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/ */

    

freshsystems / wp-permission-manager example snippets


 if ( current_user_can( 'capability_name' ) ) echo 'This user can do something'; 

 if ( current_user_can( 'read_pages ' ) ): 

if ( members_user_has_role( $user_id, $role ) ) // ...

if ( members_current_user_has_role( $role ) ) // ...

add_filter( 'members_remove_old_levels', '__return_false' );

 // e.g. functions.php

add_action( 'members_register_caps', function()
{
    members_register_cap( 'your_cap_name', [
        'label' => __( 'Your Capability Label', 'example-textdomain' ),
        'group' => 'example',
    ]);
});

 // e.g. functions.php

add_action( 'members_register_cap_groups', function()
{
    members_register_cap_group( 'your_group_name', [
        'label'    => __( 'Your Group Label', 'example-textdomain' ),
        'caps'     => [],
        'icon'     => 'dashicons-admin-generic',
        'priority' => 10,
    ]);
});

members_unregister_cap_group( "type-{$post_type}" );