Redirect user based on role when they try access a particular page

function redirect_non_vendors() { global $wp; $user = wp_get_current_user(); $role_needed = ‘vendor’; $page_to_check = ‘secret/page/url’; $redirect_url = home_url( ‘/go-here/’ ); if ( ! in_array( $role_needed, (array) $user->roles ) && $page_to_check === $wp->request ) { wp_redirect( $redirect_url ); exit; } } add_action( ‘template_redirect’, ‘redirect_non_vendors’ ); You’ll want to replace three things here: vendor: the role that someone … Read more

Add different sizes packaging boxes to orders plugin

Definitely a job for a plugin! I haven’t used it personally, but it looks like Auto Add Product to Cart can do the job for you. From the description: You can use conditions like “cart subtotal”, “products in cart”, “categories in cart”, “money spent history”, “purchase history”, “quantity of products in cart”, “quantity of categories … Read more