I'm playing around with WordPress network. I would like to import a 'contact' form for all new blogs set up. The admin should be able to view and edit entries, but not be able to create new forms.
Is this possible?
I'm playing around with WordPress network. I would like to import a 'contact' form for all new blogs set up. The admin should be able to view and edit entries, but not be able to create new forms.
Is this possible?
Sorry, you caught us outside of normal support hours, and on a US Holiday today. Thanks for your patience.
If you use a plugin like Members by Justin Tadlock, you can easily remove capabilities from specific roles, or add a new role. There are separate permissions for create_form and view_entries (and lots of other ones too) so you should be able to do what you want. Here's a screenshot of the permissions in my installation. http://min.us/m9k2NT5Dl
However, I have not tried this with multi-site, so I have no idea how it will work.
Might be fun if you gave it a go?
In the mean time, can you supply a snippet of code that will remove 'gravityforms_create_form' from a user's caps (not role). And confirm that that will deny access to gf_new_form admin page?
Sorry, can you give more information regarding why the previous solution didn't work for you?
Here are the details regarding editing caps.
http://codex.wordpress.org/Function_Reference/add_cap
Here is a snippet that doesn't work:
add_action( 'admin_init', 'do_cap_stuff' );
function do_cap_stuff(){
global $user_ID;
if( !is_super_admin() ) :
$user = new WP_User( $user_ID );
$user->add_cap( 'gravityforms_create_form', false );
endif;
}
Can you echo $user_ID and see if it contains the actual User ID? I don't recognize that variable name as a built in global in WordPress. How are you getting the user ID into this function?
http://codex.wordpress.org/Function_Reference/get_currentuserinfo
Also places the individual attributes into the following separate global variables:
$user_login
$user_ID
$user_email
Yes I have checked that $user_ID exists.
Can't believe I feel I have to say this, but no this doesn't work either:
add_action( 'admin_init', 'do_cap_stuff' );
function do_cap_stuff(){
global $user_ID;
get_currentuserinfo();
if( !is_super_admin() ) :
$user = new WP_User( $user_ID );
$user->add_cap( 'gravityforms_create_form', false );
endif;
}
What if you changed it to :
add_action( 'admin_init', 'do_cap_stuff' );
function do_cap_stuff(){
global $current_user;
get_currentuserinfo();
if( !is_super_admin() ) :
$user = new WP_User( $current_user->ID );
$user->add_cap( 'gravityforms_create_form', false );
endif;
}
No, that's pretty much the same as the snippets I write above. It doesn't work. I haven't checked capabilities internally, but the user can still create new forms.
if( !is_super_admin() ) :
$user = new WP_User( $current_user->ID );
$res = $user->add_cap( 'gravityforms_create_form', false );
error_log( "UID: {$current_user->ID}: ".print_r($res,1) );
endif;
Logs this: UID: 14:
Sorry about this comment Miramedia. I just hadn't seen it used before, I didn't doubt it existed and just wanted to make sure we have the user ID. If we have the user ID then we must have a problem with the capabilities.
Are the capabilities for that user actually being changed? If so, then maybe the wrong capability is being removed and that's why the user still can't create forms?
You can see which capability I am trying to remove. It's in the code: gravityforms_create_form.
Is there a way to remove the capability to create forms, but leave all other caps?
Instead of this:
[php]
$user = new WP_User( $current_user->ID );
$res = $user->add_cap( 'gravityforms_create_form', false );
Can you try:
[php]
$user = new WP_User( $current_user->ID );
$user->remove_cap( 'gravityforms_create_form' );