Search for Resources and Solutions

set_member_permissions registers a new permission for Team's roles

In this article i'm going to explain how to register new permissions for Team's roles. You can use the article to create Midrub's Apps and Components for the user's dashboard.

To add a new permission, please use the code below which will be called from the method load_hooks(in your app's or component's main.php).




set_member_permissions(
    array(
        'name' => 'App or Component Name', // Should be unique
        'icon' => '', // Displayed in the Team Component
        'slug' => 'team', // Should be unique
        'fields' => array(
            array (
                'type' => 'checkbox_input', // Is the type of the field
                'slug' => 'team', // Should be unique because is the field's slug. Better use app_name_slug
                'label' => 'Permission 1',
                'label_description' => 'Permission Description'
            )
        )
    )
);

To add two or more permissions:


set_member_permissions(
    array(
        'name' => 'App or Component Name', // Should be unique
        'icon' => '', // Displayed in the Team Component
        'slug' => 'team', // Should be unique
        'fields' => array(
            array (
                'type' => 'checkbox_input', // Is the type of the field
                'slug' => 'team', // Should be unique because is the field's slug. Better use app_name_slug
                'label' => 'Permission 1',
                'label_description' => 'Permission Description'
            ),
            array (
                'type' => 'checkbox_input', // Is the type of the field
                'slug' => 'team_2', // Should be unique because is the field's slug. Better use app_name_slug
                'label' => 'Permission 2',
                'label_description' => 'Permission Description'
            )
        )
    )
);

In other articles i will explain how to use these permissions.


Was this article helpful?