How to disable the “Upgrade or Downgrade” button in “My account” of WooCommerce Subscriptions

I have found/made the code that works. Maybe it helps somebody else. /** * Remove the “Upgrade or Downgrade” button from the My Subscription table if user role is “subscriber_plus”. */ add_filter(‘woocommerce_subscriptions_switch_link’, ‘remove_switch_button’, 10, 4); function remove_switch_button($switch_link, $item_id, $item, $subscription) { $user = wp_get_current_user(); if ( in_array( ‘subscriber_plus’, (array) $user->roles ) ) { return ”; … Read more

Limit user access to installing/configuring a plugin?

WP doesn’t have a built-in way to restrict permissions this granularly. You can either install plugins, or not. For settings, it depends on where the plugin surfaces its settings. For example, if the settings are under the “Settings” menu, then by default only users with role “administrator” will be able to access and adjust them. … Read more

i need to let a user to add a role from a frontend form

I think each user can only have one role. However this is how its possible to change role, if for some reason that I dont know the user can have more than one role, remove the remove role line. you can check the available roles here. $current_user = wp_get_current_user(); // Remove role $current_user->remove_role( ‘subscriber’ ); … Read more

Allow a role to edit one specific plugin

To solve this you need to go into the main .php file for the plugin and have changed the required capability using add_menu_page. I created a custom capability, added it to Contributors, and changed the .php file to allow users with that capability to view the menu.

Switch-Case and user_role

You missed break statement This is how switch case works switch ($i) { case “apple”: echo “i is apple”; break; case “bar”: echo “i is bar”; break; case “cake”: echo “i is cake”; break; }

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