ryanga1
Forum Replies Created
-
Forum: Plugins
In reply to: [Role Based Price For WooCommerce] After Update To V2.5 Not workingHi Varun:
Since upgrading to WC 2.5, I don’t get the messages above, but my /product-category pages timeout after 30 seconds with a fatal error in various /wp-includes files. I have disabled the role based price module, and everything works, and then re-enabled it and I get the timeout every time. This is a test site with no actual role based prices created yet.
Also, could you please put a hook in the current_role() function as described here: https://www.ads-software.com/support/topic/role-based-pricing-even-if-not-logged-in?replies=6
I have previously donated to the project.
Thanks!
-Ryan
Forum: Plugins
In reply to: [Role Based Price For WooCommerce] Role Based Pricing even if not logged inThanks for the help – am I correct that to do this properly, I should request a hook in the current_role function, and then write a custom filter for that function? If so, is that something I can request in the next version? ??
I appreciate your feedback.
Forum: Plugins
In reply to: [Role Based Price For WooCommerce] Role Based Pricing even if not logged inThanks for the quick reply. I think I may have solved the problem (and probably created some unwanted side effects that I haven’t discovered yet)… I discovered that:
global $current_user; $current_user->roles; // only contains roles of logged in users
But…
$user = new WP_User(get_current_user_id()); // $user->roles returns roles of the current user, regardless of logged in status (such as roles assigned with $user->add_role( 'customrole' ))
So, I changed your code a bit to:
public function current_role(){ $user_ID= get_current_user_id(); // get the current user_id $user = new WP_User( $user_ID ); $user_role = array_pop($user->roles); //global $current_user; //$user_roles = $current_user->roles; //$user_role = array_shift($user_roles); if($user_role == null){ return 'logedout'; } return $user_role; }
And now my custom roles are reflected with the custom role based pricing, regardless of the logged in status of the user. Please let me know if there is something I’ve overlooked (just learning WP coding), and thanks again!