Disable Woocommerce checkout based on user role [closed]

Woocommerce is considered off-topic here but as a general answer, it is considered best practice to check against capabilities instead of roles In WP, this is done like that: add_action(‘init’, ‘wpse_capability_check’); // hooked on ‘init’ but depends on your actual code logic function wpse_capability_check(){ // you should check on a capability that only validated user … Read more

How to add user roles? [closed]

What you want is add_role() The Codex provides sample code: $result = add_role( ‘basic_contributor’, __( ‘Basic Contributor’ ), array( ‘read’ => true, // true allows this capability ‘edit_posts’ => true, ‘delete_posts’ => false, // Use false to explicitly deny ) ); if ( null !== $result ) { echo ‘Yay! New role created!’; } else … Read more

WordPress Roles

Create function to give role a numeric value: function get_user_level($role){ switch ($role) { case ‘Contributor’: return 1; ); break; case ‘Author’: return 2; ); break; case ‘Editor’: return 4; break; case ‘Administrator’: return 5; break; case ‘Super Admin’: return 6; break; default: return 0; // default subscriber or other roles break; } } Now you … Read more

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