The code adds the functions like this:
add_action ('template_redirect', array( 'loginForm', 'set_submit_login_func'));
Which tells PHP to do this when template_redirect
happens:
loginForm::set_submit_login_func();
But we can see set_submit_login_func
in the questions code and it is clear that it is not a static function:
public function set_submit_login_func(){
What you want is a dynamic callable, e.g.
class MyClass {
public function test() { }
}
$obj = new MyClass();
add_action( '...', array( $obj, 'test' ) );
Where array( $obj, 'test' )
is the same as $obj->test()
. Notice that the first parameter is the object to call the function on, not the name of the class.
I strongly recommend reading about how to use PHP callables to understand this better: https://www.php.net/manual/en/language.types.callable.php
Related Posts:
- Redirect logged in users if they are on a specific page
- after login that will redirect user role into a page
- Redirect users on specific post category or category page
- Stuck in redirect loop after using wp_login action
- Firing a function AFTER redirect
- Redirect customer to login if not logged in when proceeding to checkout
- A good hook to check authorization and redirect?
- What hook to use to redirect based on $post
- How to read and write session data?
- Template_redirect works, but headers aren’t sent when checking via cURL
- Is there a way to send HTML formatted emails with WordPress’ wp_mail() function?
- Hook after image is uploaded and image sizes generated
- How to call a REST endpoint when a post is published?
- __NAMESPACE__ with register_activation_hook
- Hook for URL Request
- Hook/notify when any option or setting is added or updated
- Which hooks is this? add_action(‘wp’,
- admin_notices after register_uninstall / deactivate_hook
- add_action on inherit post status
- Why does wp_enqueue_script ignore my ‘wp_head’ hook?
- action lifecycle
- Returning ACF custom field from publish_post
- How to modify an add_action() inside a loop of core function
- What is the best filter where to use register_block_type?
- How get list all users who edited post?
- Hooks for Links Box [duplicate]
- Check if do_action(‘custom_action’) is hooked into?
- Hook after wp_enqueue_scripts
- wp_login Action hook with conditional tag
- Can I remove WooCommerce main content hook?
- How to alter the query using pre_get_posts hook and is_post_type_archive
- How to update WordPress core or themes and still have my child theme hooks work
- Proper indentation of code generated inside hooks
- Add parameter (time) to oembed
- How can I count post views of REST API calls and update them in an ACF field?
- Event-Driven Pattern vs MVC?
- Using hooks with extra parameters
- How to catch and modify custom field values when a page is updated
- Genesis: How to add content after aside and before the content-sidebar wrap
- new_to_publish fires multiple times
- What hook is used to display the admin_bar on the front end?
- Plugin init hook
- Best action hook for placing ical requests
- Is there a hook that fires when a row of wp_sitemeta table is updated?
- `rest_user_query` can’t access post author in post edit screen
- Post Meta Emtpy on Publish Using Transition
- How to check post type when using sanitize_title hook?
- How do I trigger a post update within a get_posts() foreach loop?
- Duplicate Cron Jobs Using wp_next_scheduled / wp_schedule_event
- Hook when editing user
- get_post_metadata causing some meta data to fail
- Add action hook into wp_localize_script
- How to change the default mail when admin approuved an user?
- How to modify how the_content outputs a link to an internal page
- read more, even if excerpt not trimmed
- How do I prevent term from being created on create_term hook?
- How to distinguish on hook profile_update user registering, user resetting password or user updating profile?
- Hook function prints output twice
- Hook priority in admin with custom plugin
- Embeding style into the header via the function.php
- ‘save_post’ hook not working in WP 3.5
- Change the Default Plugin page filter to Active intead of All
- Remove Header and Footer if user is not logged on
- Restrict access to admin-post.php
- How to execute a hook asynchronously?
- Issues with if, else, and elseif statements
- Is there a before_save_post hook or something similar
- “Seen by” Feature in posts [closed]
- How to hook in to the “output buffer” and add html content
- hook for loading page
- How can I modify the header of RSS feed items?
- Print results of a WP_Query to wp-admin/upload.php within ‘delete_attachment’ hook?
- upgrader_process_complete filter not fired using ajax updates
- How to debug wordpress hooked functions?
- remove_action(‘save_post’) in function that was triggered by save post not working
- How to get template name or category before publish
- WordPress How to reorder Page/Post Settings
- Is there a way to Insert a post to post list?
- “Intercept” enqueing of 3rd party’s JS file
- Add a Call to Action Button to WordPress Post Thumbnail
- Struggling with plugin dev basics: add_action
- RTrouble passing arguments to action
- delete_user hook failed
- Which things should be called with `after_setup_theme`?
- Changing header logo href for the checkout page
- Prefixing widget_posts_args Hook
- Can’t get ID of post that relates to the comment
- Updating user meta data from external link, user not logged in
- Remove lines from RSS Feed
- Is there a hook that triggers when grant secondary user role in WordPress?
- How can I insert custom html code inside a div dynamically?
- remove_action() hook not working
- How WordPress understands what do with the (all) key in the $wp_filter array? [duplicate]
- WP-Automatic to run publish hooks
- Hide post completely and still reach it via cURL
- Problem in register activation hook and Copying folder
- Why does hook priority affects admin menu permission error?
- How do I change TinyMCE button “i” to create a i tag rather than em? [duplicate]
- add_action failed to display function by a plugin
- woocommerce_add_to_cart_validation max quantity depending on user geoip [closed]