Customizing and overriding some functions of a WordPress plugin

I need to customize a Wordpress plugin so as to fit our local needs. I've actually changed some files from the plugin itself to fulfill the local needs, and they work like a charm. But as you all know, its definitely not a good practice, since the moment the main plugin is updated, the modified files will get overwritten, and then everything is gone. I actually want to create a new plugin and inside it I want to tell Wordpress that whenever a certain function is called, just don't do it and do another function as I determine it for Wordpress. See the following code, please:

function access_from( $id, $user_id, $product_id) {
         local_visible = Br::turn_gregorian_timestamp_to_local($visible_since);
         $current_time = Br::get_local_timestamp();
         if ( $current_time < $local_visible ) {
            $return = apply_filters('product_access_from__visibility_since', $local_visible, $product_id, $user_id );

This is not the whole code. This is only a part of it. I have just brought the parts that I need to modify so that the plugin's date and time will suit us. So here is the scenario: How should I tell Wordpress to call a specific function whenever another function is called and does it the way I determine. So that I will be able to modify some parts of plugin related to date and time. In our case, we are going to actually tell Wordpress that whenever the function access_from is called, just take its values, and put them in my modified access_from function, for example called new_access_from.

Many thanks in advance.

Read more here:

Content Attribution

This content was originally published by H. M.. at Recent Questions - Stack Overflow, and is syndicated here via their RSS feed. You can read the original post over there.

%d bloggers like this: