Viewing 4 replies - 1 through 4 (of 4 total)
  • Plugin Author Vladimir Garagulya

    (@shinephp)

    Hi Tash,

    “Caldera Forms” uses ‘manage_options” user capability to protect its menu items.

    Thread Starter tashword

    (@tashword)

    Thanks for the answer Vladimir, but I have no idea what that means in a practical sense!

    How do I now let some roles us Caldera and others now? Or are you saying we can’t assign it to anyone but admin?

    Plugin Author Vladimir Garagulya

    (@shinephp)

    ‘manage_options’ is a default value which Caldera Forms uses in its code for security purposes. You can grant access to Caldera Form to any role granting this capability to that role. Of course, it’s a critical capability, which give to a user too much power.

    Fortunately, CF developers include possibility to change a default user capability to any other using filter ‘caldera_forms_manage_cap’:

    
    public static function get_manage_cap( $context = 'admin', $form = false ) {
    		if ( is_string( $form ) ) {
    			$form = Caldera_Forms_Forms::get_form( $form );
    		}
    
    		/**
    		 * Change capability for managing Caldera Forms
    		 *
    		 * @since 1.3.1
    		 *
    		 * @param string $cap A capability. By default "manage_options"
    		 * @param string $context Context to check in.
    		 * @param array|null $form Form config if it was passed.
    		 */
    		return apply_filters( 'caldera_forms_manage_cap', 'manage_options', $context, $form );
    
    	}
    

    So you can add a new custom capability ‘manage_caldera_forms’ and return it instead of ‘manage_options’ using this filter:

    
    add_filter('caldera_forms_manage_cap', 'my_caldera_caps', 10, 3);
    
    function my_caldera_caps($cap, $context, $form) {
        $cap = 'manage_caldera_forms';
        
        return $cap;
    }
    

    I need the same thing, to give access to Caldera forms to the “Contributor” role level.
    So if I just add this code:

    add_filter('caldera_forms_manage_cap', 'my_caldera_caps', 10, 3);
    
    function my_caldera_caps($cap, $context, $form) {
        $cap = 'manage_caldera_forms';
        
        return $cap;
    }

    … is that all I need to do?

Viewing 4 replies - 1 through 4 (of 4 total)
  • The topic ‘Caldera roles’ is closed to new replies.