You need to hook it later.
add_action('template_redirect' , 'prevent_profile_access');
References:
https://codex.wordpress.org/Plugin_API/Action_Reference
https://codex.wordpress.org/Plugin_API/Action_Reference/template_redirect
Related Posts:
- How can I make an Ajax login form work with FORCE_SSL_ADMIN enabled?
- Autogenerate wordpress shortcodes using array?
- Shortcode display outside the div
- Execute a function using ajax
- How to remove action from plugin?
- What’s the point of using WordPress’s built in admin-ajax.php?
- wordpress custom login successful redirect hook
- jQuery Plugin to use WordPress functions in AJAX request
- ajax front-end increment views on click
- WordPress Plugin Page is Loading in Admin Content Container Instead of Separate Page
- Shortcode button dosent work for all posts. Work for first post only
- AJAX button run function
- How to stop or remove an action being called inside a function of an extended class
- wordpress plugin is not activating from widget
- Calling plugin function inside custom plugin for onclick event
- Ajax : Call undefined function plugin_function() … can’t call any plugin function
- What is @Action in WordPress?
- Submit Form data to another page via Ajax (WordPress Way)
- Create a post builder skin in a plugin
- Plugin Development – Functions or Hooks?
- PHP script from functions php is loaded via admin-ajax to div…and the result is 0, not the desired content
- Are there action hooks for comments?
- How to get specific string/value from an array? php [closed]
- Where Should i write the code for wordpress ajax voting?
- How to remove a class function from a plugin by using remove_action()?
- Add action to custom Function
- wp_ajax action responds with 0
- grab or load text on demand
- Cannot pass value variable to WP AJAX functions
- The function called on the wp head hook becomes null
- Sharing varible between two add_actions
- Discern a specific plugin’s action hooks
- How to Unhook actions/filters in within Class in plugin
- WPML – Hook when language is switched (change user language)
- Use action, filter, or hook to append HTML to WordPress plugin function
- Ajax call to php function doesn’t work PHP code
- Update User Meta Via Ajax
- Compare Ajax Data Results
- Frontend AJAX Request causes Error: ‘Call to undefined function add_action’
- Why is WP template_include overwritting all templates rather than specified page?
- My ajax request don´t work and return 0
- WordPress environment not loading properly
- wp_login_form() ignoring login_form action hook
- how to repeat taxonomy in different places on wordpress
- Trouble Removing Plugin [closed]
- add query string to all pages after user logged in
- Call a function with href
- How to load wp_editor via AJAX
- Deactivate plugin for a specific user group
- Remote upload file to server B
- Using functions from a plugin in your theme
- Keep one user logged for a year?
- How to add a sub menu with AJAX?
- How to turn off email you receive when registered?
- Add custom buttons with custom actions in Edit Post screen in WordPress?
- Converting a simple plugin to be placed inside of functions.php
- How to get subscription key or id using Woocommerce Subscriptions [closed]
- How to include code into functions.php file via a plugin
- Show function to super admin
- Custom plugin init action causing general slowness
- admin-ajax.php warning max input vars exceeded on layered pop plugins [closed]
- Using AJAX to generate front end / viewer end pages
- do add_action on condition
- publish_post action doesn’t work
- Plugin is a widget, but I want to call it in the head, can I?
- Cannot get wpdb data (Error in a simple fuction) [closed]
- AJAX Load more start with x posts
- Help with WP Business Directory Manager Plugin?
- Loading a plugin’s js file from functions.php
- Asynchronous request in wordpress
- How to access OOP plugin function inside themes or other plugin
- Elementor Pro display featured image on section -> style -> image using shortcode
- RSS feeds for specific topics
- Facing Problem with admin-ajax.php URL – Getting 404 with AJAX call
- jQuery Ajax not loading page with ACF fields
- Adding discount functionality to the cart
- Use buddypress function outside of plugin
- Passing function into add_action always returns the first argument
- On button click, redirect users to registration page instead of another page
- Save Post Permalink In .txt File
- Change hook to add_action in a plugin class
- wp_ajax add_action fuction won’t fire on custom jQuery action
- How To Add Code To WP Without Plugin or Functions
- Disqus comments count taking long to update
- plugin not hooking to my custom hook
- Populate select option with JSON file
- wp-admin will not redirect to wp-login.php
- display user input using ajax in wordpress
- Load wordpress enviroment for external content?
- How to structure plugin in to functions?
- WordPress plugin ajax post parameter
- Response from Php File to Ajax is not getting sent
- Plugin Admin Page Ajax-Admin call returning 0, URL set correctly. Implemented localized scripts but did not fix it
- How to disable register and reset the password from WordPress admin panel?
- What is wrong with this dbDelta syntax?
- Adding a script & php to functions.php
- How to disable plugin capability : “create new category”
- Ajax Called in Plugin php file
- Ajax Load More stopped working (Plugin with repeater template, shows hidden Button)
- Shortcode cannot parse attributes within double quotes. ” is becoming ” breaking my shortcode