Skip to content

Instantly share code, notes, and snippets.

@Shelob9
Last active October 18, 2020 19:29
Show Gist options
  • Save Shelob9/60538a46cdb02381570718522f2e85e6 to your computer and use it in GitHub Desktop.
Save Shelob9/60538a46cdb02381570718522f2e85e6 to your computer and use it in GitHub Desktop.
Examples of how to change the capabilities for what kind of user can use Caldera Forms admin via the caldera_forms_manage_cap filter SEE: https://calderaforms.com/doc/caldera_forms_manage_cap/
<?php
/**
Allow users with the editor role to use the Caldera Forms admin screen
*/
add_filter( 'caldera_forms_manage_cap', function( $cap, $context ) {
if( 'admin' == $context ) {
return 'edit_pages';
}
return $cap;
}, 10, 2 );
<?php
add_filter( 'caldera_forms_manage_cap', function() {
return 'delete_posts';
}, 51 );
<?php
/**
Change capability for editting Caldera Forms entires
*/
add_filter( 'caldera_forms_manage_cap', function( $cap, $context ) {
if( 'edit-entry' == $context ) {
//choose a capability of the role you wish to allow
return 'create_posts';
}
return $cap;
}, 10, 2 );
/**
Change capability for deleting Caldera Forms entires
*/
add_filter( 'caldera_forms_manage_cap', function( $cap, $context ) {
if( 'edit-entry' == $context ) {
//choose a capability of the role you wish to allow
return 'edit_pages';
}
return $cap;
}, 10, 2 );
@flofigit
Copy link

flofigit commented Sep 11, 2020

Hi,
any news on that? What to do extactly to allow editors to create and clone forms? Would be great if anybody can help.
No luck with the following code in functions.php:

add_filter('caldera_forms_manage_cap', 'my_caldera_caps', 10, 3);
    function my_caldera_caps($cap, $context, $form) {
        $cap = 'manage_caldera_forms';
        return $cap;
    }
/**
    Change capability for editting Caldera Forms entires
     */
    add_filter( 'caldera_forms_manage_cap', function( $cap, $context ) {
        if( 'edit-entry' == $context ) {
            //choose a capability of the role you wish to allow
            return 'create_posts';
        }
 
        return $cap;
    }, 10, 2 );
 
    /**
    Change capability for deleting Caldera Forms entires
     */
    add_filter( 'caldera_forms_manage_cap', function( $cap, $context ) {
        if( 'edit-entry' == $context ) {
            //choose a capability of the role you wish to allow
            return 'edit_pages';
        }
 
        return $cap;
    }, 10, 2 );

@camilolunacom
Copy link

Any luck with this? I haven't been able to resolve this issue.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment