Add Api permissions from your apps or components
Almost any script's you've seen for sale which has Api support, provides unlimited use for their Api. You can use their Api as you want without limits. In Midrub from the start the Api was based on permissions. Based on permissions, the developer can decide which permissions will have his feature developed in Midrub.
To add a new Api's permission or a list with Api's permissions in Midrub you have to use the hook:
The hook should be registered from the component/app method load_hooks when the category is admin_init. Otherwise won't work and will generate errors.
How the hook works? For example you have the app called myapp. In the app myapp you have data to read, create and delete. So, you don't want to allow users to delete or create content from your app. You will create a permission:
set_admin_api_permissions( array ( array( 'name' => 'Read', // Displayed permission name 'slug' => 'read', // Displayed permission slug 'description' => 'Users will be able to read content', // Description for admin 'user_allow' => 'App will be able to read the content' // Permission to approve displayed to user ) ) );
In the next article i will explain how to verify if user has approved that permission to read the content.
My way with Api's permissions allows to developers to be independent. They will decide what kind of permissions will have their Api endpoints created in their Apps or Components.
From 0.0.7.9 Midrub has a more powerful core for Api and it will provide a lot of features.
In the video below you will see how works the code above:
- Add Api permissions from your apps or components
- How to send email in Midrub and how understand why you're emails aren't sending
- How works the Quick Scheduler to publish posts with several clicks
- How to create a new menu for the user's panel
- the_db_request in midrub frontend themes
- Midrub Core Introduction
- Midrub User Introduction
- How to enable or disable apps and components for a Team's member
- Midrub Apps Structure
- Midrub Team Introduction