Skip to content

Instantly share code, notes, and snippets.

@nkb-bd
Created March 14, 2023 12:21
Show Gist options
  • Save nkb-bd/b0968c015b34287e7687257820154637 to your computer and use it in GitHub Desktop.
Save nkb-bd/b0968c015b34287e7687257820154637 to your computer and use it in GitHub Desktop.
Single Form Admin Access for Fluent Form
//First Set all permission for the user from the settings
add_action('init',function (){
$userId = 18; //Enter User ID (except admin)
$formId = 11; //Fluent Form ID
customPermissionRule($userId,$formId);
});
function customPermissionRule($userId,$formId){
if($userId != get_current_user_id()){
return;
}
$allowed = [
'fluentform_dashboard_access',
'fluentform_entries_viewer',
];
$array = [];
$availablePermission =(array) \FluentForm\App\Modules\Acl\Acl::getPermissionSet();
$isFluentAdminPage = isset($_GET['form_id']) && $_GET['form_id'] != $formId && FluentForm\App\Helpers\Helper::isFluentAdminPage();
if ($isFluentAdminPage) {
foreach ($availablePermission as $permission) {
if (in_array($permission, $allowed)) {
$array[] = $permission;
add_filter('fluentform_verify_user_permission_' . $permission, function () { return true; });
} else {
add_filter('fluentform_verify_user_permission_' . $permission, function () { return false; });
}
}
add_filter('fluentform/current_user_permissions', function () use ($array) {
return $array;
});
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment