Allow author to duplicate but not edit post

Duplicating a post is a 3-step process: Create a new post using data from the source post. Copy the source post’s metadata over to the new post. Copy the source post’s terms over to the new post. Since you’re only reading from the source post, duplicating is not more of editing, as you suggest. Here … Read more

Changing second user role while updating/downgrading membership level – s2member [closed]

I found a solution. Here it is: //Update Roles automatically when Membership Level changes function rb_update_user_role( $user_id) { $user = new WP_User( $user_id ); $user_meta=get_userdata($user_id); $all_role = $user_meta->roles; foreach ($all_role as $role_value){ if ($role_value === ‘vendor’){ $user->remove_role( ‘vendor’ ); } if ($role_value === ‘customer’){ $user->remove_role( ‘customer’ ); } if ($role_value === ‘s2member_level1’){ $user->remove_role( ‘s2member_level1’ ); … Read more

Change the second role depending on the first

Because you are operating on the current (logged in) user – you need to accept parameters in your callback so that you can operate on the user whose role is being set: rb_update_user_role( $user_id, $role ) { // error_log( “Setting user $user_id to role $role” ); if ( $role !== ‘s2member_level0’ && $role !== ‘s2member_level1’ … Read more

How can I add the ability for a user to add/edit administrators?

Make sure you’re adding and removing roles on plugin activation/deactivation. add_role() only adds a role if it doesn’t already exist. So if you already added the developer role without the capability to add administrators, calling add_role() again won’t re-add the role. You have to remove the role first. <?php /** * Plugin Name: Stackexchange Sample … Read more

Show modal only to some roles

You need to put that code in the php file of your child theme relative to where you want it to appear and on what pages. So if you want it to appear on a blog page you would place it in your single.php file right under your call for content ( the_content() ) Alternatively, … Read more

Role exception for a settings sub menu

You can see here a list of roles and capabilities, if you want to check if the user has a certain role, you can: $the_user = wp_get_current_user();//we get the current user if ( in_array( ‘the_name_of_your_role’, (array) $the_user->roles ) ) { //the user has the rol, add the submenu here } you can use current_user_can if … Read more

Hata!: SQLSTATE[HY000] [1045] Access denied for user 'divattrend_liink'@'localhost' (using password: YES)