Hot answers tagged

3

I think you are on the right track, wp_cache_delete was what finally helped me get an auto-signup with auto-login plugin working... I have this from there: wp_cache_delete($current_user->ID, 'users'); wp_cache_delete($current_user->user_login, 'userlogins'); Then see what roles you get after that with: $current_user = wp_get_current_user();


2

As the keys already hold PHP generated output, it should be possible to simply wrap them in some MarkUp woocommerce_wp_select( array( 'id' => 'productstatus_select', 'label' => __( 'Product Status', 'woocommerce' ), 'options' => array( 'Message one' => sprintf( '<span ...


2

You can do in the following way! Create an array of CSS class names and message values $colors_stings = array( 'Message one' => 'message_color_green', 'Message two' => 'message_color_red', 'Message three' => 'message_color_blue' ); Check if message string exist in array then assign CSS color class to variable. $css_class = ...


2

Sorry I can not comment yet on this site Could you be removing an action before it is registered? Have you tried wrapping this with an on init hook? Perhaps using remove_filter would be a better choice. function my_init() { remove_filter( 'storefront_header', array( 'Galleria_Structure', 'galleria_top_bar_wrapper' ) ); remove_filter( ...


2

Ok I found out the solution. Because, as I said, WooCommerce has it's own hooks, first of all I've searched for a WooCommerce hook about registration. I discovered the existence of a hook very similiar to the one used by WordPress: woocommerce_registration_errors. Obviously it works in the same way. Then I simply replaced the WordPress hook with the ...


2

Have you tried logging in the user after your changes? Such as: wp_set_current_user( $current_user->ID, $current_user->user_login ); wp_set_auth_cookie( $current_user->ID ); do_action( 'wp_login', $current_user->user_login );


2

First add the following code (and probably the WC Test Payment Gateway) and do a test order to get a list of all the data keys that are set in the order process via the woocommerce_after_checkout_validation filter: add_action('woocommerce_after_checkout_validation','custom_modify_order',10,1); function custom_modify_order($posted) { foreach ($posted as ...


2

is_category() only check the built in post category. Product categories are custom taxonomies. So you need to use is_tax() instead of is_category() and get_term() instead of get_category(). Check this example:- function is_subcategory($cat_id = null) { if (is_tax('product_cat')) { if (empty($cat_id)){ $cat_id = ...


1

Quickie Run only when you need to run and only run where you need to run Your code is almost there but you are not running at the particular time,if we use the your code it runs first and then filtered again by WooCommerce. So we have two options. Change priority of the filter Hook the code to run properly I think just unsetting ...


1

You can wrap it in the same check used for $category: <?php if (isset($term->term_id)) { echo '<a href="'.get_term_link($term).'">'.$term->name.'</a>'; } ?> or check to make sure it is not an error object: <?php if (!is_wp_error($term)) { echo '<a href="'.get_term_link($term).'">'.$term->name.'</a>'; } ...


1

Use wp_login_url. <a href="<?php echo wp_login_url(); ?> ">login</a> To redirect to home page after login, add the $redirect argument and point to home_url() <a href="<?php echo wp_login_url( home_url() ); ?> ">login</a>


1

You don't need to! With a little understanding of how URLs and query vars work, we can do this entirely within the URL of the page, with no additional PHP code First we have a URL: example.com/abc/123 Then we have a rewrite rule. The rule has a regex pattern that matches the URL, and a second bit that says were all the bits that match go, e.g. ...


1

A minor update (I ran into this issue today): The above solution does not work anymore. The only thing you need to do nowadays is to set the post_parent: wp_update_post(array( 'ID' => $booking->id, 'post_parent' => $order->id ));


1

That is due to the fact, that your filter woocommerce_breadcrumb doesn't even exist. This filter here works and pulls out all the elements, that are currently in the breadcrumb (as an array): add_filter( 'woocommerce_get_breadcrumb', 'change_breadcrumb' ); function change_breadcrumb( $crumbs ) { var_dump( $crumbs ); return $crumbs; } And this ...



Only top voted, non community-wiki answers of a minimum length are eligible