term_link filter rewrite link only applying half of condition?

Thanks Lucas! I found this code as an example in several places … still interesting that the && doesn’t work … but this does 🙂 add_filter( ‘term_link’, ‘slick_term_to_page’, 10, 3 ); function slick_term_to_page( $url, $term, $taxonomy ) { if ( $term->term_id != 42 ) : // if ( $taxonomy != ‘highlight’ && $term->term_id != 42 … Read more

Handle multiple parameters in filter

The problem is that you use apply_filters incorrectly. This function takes at least two parameters: $tag (string) (Required) The name of the filter hook $value (mixed) (Required) The value on which the filters hooked to $tag are applied on. So the first param should be the name of the hook and as second param you … Read more

why require – does not load filter

The filter itself probably works, but the file_exists() returns false. So not sure if this answers the question, but one issue I see in your code is: When you put the code in your-plugin/admin/partials/ggowl_template/ggowl_template_func.php, plugin_dir_path( __FILE__ ) from within the ggowl_template_post_function() would be your-plugin/admin/partials/ggowl_template/ — and not the main plugin file path, so I suggest … Read more

How to strip out javascript in wp_posts `post_content`

If the javascript code is actually embedded in the post content, you could use php filters such as the_content to remove script tags. But that will strip it out at runtime, every time the page is loaded. If this is your situation, then you’d be better off stripping it out of the wp_posts.post_content table/column from … Read more

Conflict calling an add_filter() twice

Filters get queued and sorted by priority, then order of occurrence. Filters’ default priority is 10, unless otherwise specified. The order of occurrence can be affected by the order plugins get fired (alphabetical, by plugin name). So, when you started poking at this, both filters had equal priority. That would mean a rather arbitrary factor … Read more

How to override include_once pointed file using add_filter?

You can’t just filter __FILE__. Or any arbitrary function or variable. You can only filter values that are passed to apply_filters(). In this case the wcpv_vendor_order_page_template filterable value is: dirname( __FILE__ ) . ‘/views/html-vendor-order-page.php’ In other words, it’s a path to a PHP file. If you want to change the PHP file that’s loaded, you … Read more

Prevent reset password specific user role

Your problems are you’re testing if($user->ID){, i.e. does the b2b_account user object we’ve found have an ID. Which it always will. You probably meant to compare it to $ID. you need to return true in the success case, i.e. after your for loop if you didn’t find the user. However you’re ignoring the $allow parameter. … Read more