Your function does not have to accept all arguments, you can not specify the number of accepted arguments and it will default to passing just the first.
You can also specify any number up to and including the total number of arguments. For example if you only need the first 2, this will also work:
function my_filter_func( $redirect_to, $requested_redirect_to ) {
// My code.
}
add_filter( 'login_redirect', 'my_filter_func', 10, 2 );
What you can’t do is use more arguments than what you specify in your add_filter
call. For example, this will generate a missing argument 2 warning:
function my_filter_func( $redirect_to, $requested_redirect_to ) {
// My code.
}
add_filter( 'login_redirect', 'my_filter_func' );
Related Posts:
- Change the footer text on the login page
- Check if page parent has certain template
- Handling Body class based on Template
- WordPress Gravatar filter is removing my custom attributes
- Generating an nonce for Content Security Policy and all scripts – How to make it match/persist for each page load?
- How to have different site identity logos on each page on Astra Theme [closed]
- Assign new post author IF another user in custom field on post transition
- Is there a hook that I can use when a fatal error occurs?
- How to make a image-size selected by default in Media upload – WP v3.5
- Apply class to every paragraph that holds image?
- static variable loop not working in WordPress
- adding a filter to a shortcode?
- Set media upload attachment link to none and hide it in WP v3.5
- How can I hook into and edit the text of a wp_nav_menu tag?
- How to remove a metabox from menu editor page?
- add_filter to post-gallery and remove all ‘s?
- How to overwrite youtube embed?
- Rewriting search and pagination base
- How to remove “out of stock” variation options from size dropdown in woocommerce?
- Change comments form title on a page by page basis
- Remove class that has been added by parent theme
- Hooking new functions to actions + passing parameters
- How do I know what variables are passed in a filter/action and what their meaning is?
- Find variables available at a given hook
- Why do filters/actions require an argument count?
- Is $hook a global variable in WordPress
- Getting my head round WordPress filter
- How to set a custom path, for ajax image upload folder in admin?
- WooCommerce: Add Payment Gateway Field to Webhooks [closed]
- How to use return in my custom function instead of echo
- When using the_author hook, how can I determine the PHP file that generates each call to `the_author()`?
- How to call function at the bottom of post using plugin?
- Run a filter when a walker runs
- Randomise upload filenames (or another solution to hide the original image URL from theft?)
- Get_avatar filter?
- How can I remove a function that has been added to wordpress with add_filter?
- How to control WordPress image metadata (using Imagick)?
- Edit incorrect password message WordPress
- How do I add custom bulk actions to multiple custom post types?
- Add data attribute to each li in menu
- Contact Fom 7 – how to add custom HTML inside span.wpcf7-form-control-wrap AND IMMEDIATELY AFTER input.wpcf7-form-control?
- Removing “wpautop” (auto tags) only on certain pages?
- Woocommerce: hook action/filter I could use to add variation id and price with each attribute opt on WooCommerce Rest api
- Remove a div from RSS feed
- Is it possible to intercept all ajax requests and get the parameters and the returns?
- How to add an arrow to menu items has submenus
- Error in custom php function doesn’t exist
- Unique icons next to each WordPress menu item
- Modify custom field input data before creating a new post
- how to make custom ajax handler?
- Alter required message using comment form api
- Override a function defined in wp-includes/comment-template.php
- Omit custom post type from wp-sitemap.xml based on meta key using wp_sitemaps_posts_query_args
- Run a code only on theme activation only during first activation
- Filtering a function’ output for a new continued function
- Deleting Certain terms from appearing on the front end as links
- Theme not calling Jquery properly
- Content filter won’t work
- WordPress redirect redirecting too many times or not at all
- Why does the post_type_link hook everything twice?
- Warning: in_array() null given in PHP function
- Upload multiple files in randomly generated folder using wp_upload_bits
- Create page template via functions.php?
- Add meta tags to a custom header
- Get user custom field value on function.php
- Custom query vars filters problem with pagination
- Adding function to child theme’s function.php
- Get the name of menu item with wp_nav_menu
- How to add aria role and schema markup to custom walker container
- Creating customized php files in theme folder
- Dynamically Generate Functions and Hooks
- User filter posts by year
- How to sort WooCommerce products page by latest in-stock items first?
- Filter wordpress posts without searching the keywords in the post content
- Variation prices breakdown only for single product page
- How do I add a function to parent theme
- Contain multiple page templates in one PHP custom template file in WordPress?
- Wp_Schedule_Event every few minutes doesn’t work
- Apply function.php filter only if url not has /amp/
- Fatal error: Uncaught Error: Class ‘WP_Block_Styles_Registry’
- Custom meta box is not displaying value showing tag as empty
- using filter and hook inside class
- How to bind each “the_content” elements to a custom variables
- How do I get the value of a current user’s custom field?
- add_filter() inside another add_filter()
- Custom Bulk Actions handler not firing
- Getting page / post URL on publish and / or update
- How to generate customized filtered output for the gallery
- Add class to all meta boxes for a custom post type
- Fatal error when using array_diff() function inside of wp_update_nav_menu hook?
- Search box background on a different page template
- Display a list of users with avatar filterable with alphabets
- How to add custom checkout field in user details mail template
- AJAX: WordPress filters inside $html do not work as intended
- For each loop will not append to the_content hook
- Create and publish a new post every Monday, listing the post titles and links to the posts published during the previous week
- Add attribute to featured image with filter (wp_get_attachment_image_attributes)
- How to add different menu items on different menus?
- transition_post_status hook, works – but not if the post is new
- Add text below WooCommerce short description if metabox value is true