How to correctly override a filter?

Try: function allow_daniel_edit( $caps = array(), $cap = ”, $user_id = 0, $args = array() ) { if ($user_id == 59) { return array( ‘bp_moderate’ ); // or some other permission or additional permissions } return $caps; } add_filter( ‘map_meta_cap’, ‘allow_daniel_edit’, 999, 4 );

Passing value from one hook to another

The solution for this was a compromise I moved the code from the wp_login hook into my meta_links function and test to see if my value exists function dk_plugin_meta_links( $links, $file ) { if($latestversion == “”) { //get the latest version if we don’t already have it } (do something with) $latestversion; } add_filter( ‘plugin_row_meta’, … Read more

How to remove a filter that is an object method?

That’s a very good question. It goes down to the dark heart of the plugin API and best programming practices. For the following answer I created a simple plugin to illustrate the problem with easy to read code. <?php # -*- coding: utf-8 -*- /* Plugin Name: Anonymous OOP Action */ if ( ! class_exists( … Read more

Query Multiple Filters, one with Meta

Okay, I muddled around until I found what I feel is the best solution. Please feel free to offer any constructive criticism. I concluded this was not possible with a single query, so I broke it into two queries. The basic idea is to get all items matching each query, loop them to build an … Read more

Using two posts_orderby add_filter makes conflict

In the database definition of WP, in the table that links posts to terms, there is a term_order field. But this term_order is the order in which the terms are assigned to the post, NOT the order in which posts are assigned to a term. You can see the intent behind the term_order field in … Read more

Replacing text using add_filter

I just managed to fix it using string replacement function in php. function replace_btn_text( $more_dtls_link, $view ) { $link = htmlspecialchars($more_dtls_link); $str = str_replace(‘More Details’, ‘View Details’, $link); $new_link = htmlspecialchars_decode($str); return $new_link; } add_filter( ‘awsm_jobs_listing_details_link’, ‘replace_btn_text’,10, 2); Suggest me if I need to do any improvements here..