When it comes to user roles there are always restrictions. I like to allow my clients access certain areas of their website but not all of them. One feature I would like my clients to have access to is the Elementor contact form submissions so they can view new and old submissions. Unfortunately, the Elementor form submissions is only available to WordPress administrators. This WordPress plugin will allow other user roles such as author, contributor, and editor to view the Elementor contact form submissions in 3 easy steps.
Step 1. Download this .txt file or copy and save the code below as a .txt
Step 2. Save the file as elementor-form-submissions-access.php and place it in the wp-content/plugins/ directory.
Step 3. Go into the Plugins and activate it.
To see that it worked, login as an Editor and you will see a menu item for editors to view the Elementor contact form submissions.
A big shout out to the developer, Paul Tero, for this plugin that allows other user roles to view submissions from Elementor contact form!
hanlders]
* @return array [endpoints=>hanlders]
*/
static function filterRestEndpoints($endpoints)
{
if (self::isJustEditor())
{
error_reporting(0); // there are a couple of PHP notices which prevent the Ajax JSON data from loading
foreach($endpoints as $route=>$handlers) //for each endpoint
if (strpos($route, '/elementor/v1/form') === 0) //it is one of the elementor endpoints forms, form-submissions or form-submissions/export
foreach($handlers as $num=>$handler) //loop through the handlers
if (is_array ($handler) && isset ($handler['permission_callback'])) //if this handler has a permission_callback
$endpoints[$route][$num]['permission_callback'] = function($request){return true;}; //handler always returns true to grant permission
}
return $endpoints;
}
/**
* Add the submissions page to the admin menu on the left for editors only, as administrators
* can already see it.
*/
static function addOptionsPage()
{
if (!self::isJustEditor()) return;
add_menu_page('Submissions', 'Submissions', 'edit_posts', 'e-form-submissions', function(){echo '';});
}
/**
* Hook up the filter and action. I can't check if they are an editor here as the wp_user_can function
* is not available yet.
*/
static function hookIntoWordpress()
{
add_filter ('rest_endpoints', array('ElementorFormSubmissionsAccess', 'filterRestEndpoints'), 1, 3);
add_action ('admin_menu', array('ElementorFormSubmissionsAccess', 'addOptionsPage'));
}
}
ElementorFormSubmissionsAccess::hookIntoWordpress();
} //a wrapper to see if the class already exists or not
I found this solution from a github community form: https://github.com/elementor/elementor/issues/14634 where user paultero posted his WordPress php file.
Published
2023/04/04