I was almost correct in my attempt.
- I forgot to add the arguments in my function definition, which is important of course.
- I took the wrong function name, the
_summary
at the end was not needed.
The correct code is the following:
/* DISABLE ADD TO WISHLIST FOR USERS WHO AREN'T ADMIN OR SHOP MANAGER */
/* --- */
function remove_add_button ( $allow, $product ) {
$allow = false;
$product = $product->get_id();
return $allow;
return $product;
}
$user = wp_get_current_user();
if ( ! in_array( 'administrator', (array) $user->roles ) && ! in_array( 'shop_manager', (array) $user->roles ) ) {
add_filter( 'tinvwl_allow_addtowishlist_single_product','remove_add_button', 15, 2 );
}
As you can see I have also added a condition on the user role, so only admins & shop managers can use the button.
Related Posts:
- Passing a parameter to filter and action functions
- Get a list of all registered actions
- How can I edit post data before it is saved?
- How to only hook on Single.php after content?
- How To Determine If A Filter Is Called In A Sidebar/Widget Context?
- Edit plugin without hooks in functions.php
- Filter Hook on plugin update
- Hide WordPress Plugin Deactivation Links
- Use external link in the add sub menu
- Pass A Value From Outside To A Plugin Variable
- Failed to invoke other hook from the init hook
- Does the ‘nav_menu_css_class’ filter accept 2 or 3 arguments?
- do_action and hook methods
- How can I filter blog name?
- why does the add_action(‘the_content’) overwrite my page
- How to filter content post only on save
- Filter or action hook to insert content on admin pages before tag
- plugin_action_links_{$plugin_file} hook not in the main plugin file
- Woocommerce Shipping module available only for type of products [closed]
- Determine plugin name from within plugin_action_links filter
- merging an array to an existing array using add_filter
- Reposition Woocommerce Message
- Randomize attachment IDs
- Pass info from functions.php to plugin
- Change permalink structure hidden button edit
- How do action and filter hooks understand where to look for the core function that we hooked our function to them
- Inserting above the comment template
- Modifying the comments section through a plugin regardless of theme
- Get Time Taken By Each Action Hook in WordPress
- Filtering WooCommerce Orders by Category
- Template filter for custom taxonomy terms
- Add sub menu page in your plugin
- What exactly happens to function argument availability when using a filter?
- remove_action not removing add_action from constructor
- How to use the pre_option filter before a plugin loads?
- WordPress: Add custom add_filter for custom functions
- Hook for altering the content of all wp mails
- How to hook into action/filter call
- Use a hook or filter, or overwrite this Gamipress function?
- Add hook after content without formatting
- Unpublished Pages Failing To Appear On Custom Path
- Randomize post (and page) IDs on generation
- Plugin function in child theme
- Use action, filter, or hook to append HTML to WordPress plugin function
- Customize plugin templates
- Why can’t I shove an instance of a class into a variable from a do_action hook?
- Passing a parameter to filter and action functions
- change output location of plugin function using a custom hook
- add query string to all pages after user logged in
- Order shipped by which driver[hook for woocoomerce order staus changed and popup in admin panel ] [closed]
- How to Add Extra Text In WordPress Title Before Post Publish
- Change social icon in twenty twenty three theme
- Changing the “Plugin Activated” Message Default
- Hooking in to plugins
- What characters are allowed as a shortcode tag and how should they be sanitized?
- Can we hook a static method of a class to add_action inside that class?
- What is the ‘admin_action_’ . $_REQUEST[‘action’] hook used for?
- Filter out results from REST API
- How can I remove a hooked action created by a plugin?
- disable active plugins for specific theme
- Twillio How To Send SMS for Custom Post Type
- Find out if request is for custom post type archive before query runs
- Very stubborn wp_register_script / add_action vs remove
- Remove action from a plugin class, forced to use global instance
- remove filter which calls a public static function
- How to prevent action in ajax request, when in admin side?
- Placement of Code in Plugin for hooking `save_post`
- How to remove xmlns on language_attributes()?
- How to initialize something in unit test before the init hook being called?
- add_filter comment_edit_redirect not working
- How get a value from a plugin into another plugin through action/filter
- Edit default comments page in WP Admin
- Creating a plugin to sanitize comment and the url field before display only
- Are functions in main plugin file called before function bound to register_activation_hook runs?
- How to disable a plugin for certain page?
- WordPress user account activation
- password_reset hook is not working
- How to change the name of the “edit my profile” link in the WordPress admin backend
- Can my hooked uninstall class function access a global var declared in main plugin file?
- Add a function call after content automatically?
- How to use add_action for multiple instances of the same class
- How to Use the Filter “sidebar_login_widget_form_args”
- is there a way to pass a parameter to a add_menu_page function?
- How to automatically activate users after registration without activation email?
- Hooks to run after a core upgrade?
- Edit post image attributes on fly?
- Adding an item to an anonymous array inside a filter?
- Modify function output in a plugin
- Display Woocommerce attribute name above product title
- WordPress Boilerplate Plugin doesn’t see callback functions for add_settings_field and add_settings_section
- Help needed with woocommerce (wc stripe) filter
- What is the correct entry point for capturing coverage data
- Publish check if the edited content has HTML “div”
- passing ‘&’ in return function of add_filter
- Display_rows() and column_cb() strange behaviour
- Filter for modifying image on upload
- County Finder form/plugin?
- How wordpress plugin hooks works? [duplicate]
- Post curl function save twice using plugin hook function wordpress
- FacetWP custom display based on post type [closed]