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?
- Remove “Insert from URL” link in Media upload – WP 3.5
- 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 Change The Html of Products filtration sidebar in Woocommerce?
- How to set a custom path, for ajax image upload folder in admin?
- Insert all post IDs in new database table
- 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?
- Add a class to the anchor tag on HTML5 gallery
- add_action shortcut?
- 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
- Why ajax doesn’t work on certain wordpress hooks?
- Remove a div from RSS feed
- Is it possible to intercept all ajax requests and get the parameters and the returns?
- Print last modified date only on posts
- How to add an arrow to menu items has submenus
- Error in custom php function doesn’t exist
- Return a numerical function value in Customizer controls
- 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
- Add item to top of menu using a filter in functions.php
- How to make modifications only to certain elements of an HTML string on the server-side?
- 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
- How can I hook into the wp_mail function used by BackWPup?
- 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
- Woocommerce Price Text
- Limit Taxonomy Parents
- WordPress HTML Helper
- Display a post based on its metabox selection
- 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
- How to pass value to add_filter wpcf7_form_tag from another function?
- Add text below WooCommerce short description if metabox value is true
- Unable to logout correctly after wp-login file was modified
- how to append ACF field data using one of the following filter/ hooks
- Adding Author Filter to CPTs
- How can I display formatted content using the_content filter?