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
- Simple ajax request with Vanilla JS keeps given 400 Bad Request
- How to not allow users to create new tags, but allow to them to use existing ones
- Remove Google Fonts Which Are (Probably) Added By Plugins
- Editor access to plugin settings
- How to pass JavaScript variable to PHP in wordpress widget?
- Custom Widget outputs the input but doesn’t save anything inside the textarea
- Can wp_script_is used in pluginA check if a script is being enqueued/registered from pluginB?
- $wpdb working with ajax but showing ajax error instead of success
- Where to place custom functions?
- Why do plugins that cause ‘unexpected output’ create AJAX problems?
- “Request has expired” with “Make your site social” (Gigya) plugin
- creating html reusable blocks via shortcodes
- Fatal error: Call to undefined function cmsms_theme_page_layout_scheme()
- Disqus deleted comments are syncing with wordpress but active comments do not
- Difference and examples of esc_attr__() and esc_attr_e()
- add_action in a custom plugin
- Add action to fire when a published post is updated
- AJAX fileupload – TypeError: not a function ajaxSubmit()
- Proper way to use plugin functions in functions.php
- Why AJAX response 0!
- Custom CSS not being added by plugin
- auto activate plugin when theme is active
- Checkbox show / hide output result
- How to keep plugin (media-sync) running even the tab is closed?
- Load CSS before Theme CSS
- Custom Logo Link WordPress
- Where do I put the code snippets I found here or somewhere else on the web?
- How to convert Currency from USD to other IP Based currency in Php function
- How do I reinit WordPress plugins dynamically using jS?
- Attempting to list all product categories and the price range of all products within them
- function post to trash problem
- Get post content inside plugin class method
- Ajax Load More on Hierarchical Categories
- Creating new option (add_option) from AJAX – Settings API
- How to limit each front-end user to view just his own uploaded files on Amazon S3?
- Cannot access variables within a widget
- Redirect default login page to a custom page [duplicate]
- ajax request not returning the result
- How do I convince this button to do something when it is clicked?
- WordPress plugin options need to delete after deactivate & uninstall
- add_media_page function not creating submenu
- Filter for modifying image on upload
- First argument is expected to be a valid callback for cp_admin_init and _canonical_charset
- Doing action based on input from options menu
- Ajax button “Load more” is not loading correct language version posts for logged out users
- How to Allow Users to Select Recipients In a WordPress Comment section?
- How often should I execute add_filter and function declaration in Code Snippets?
- Product customizing quiz – quiz adding products to the cart
- How to change all the urls of the WordPress site?
- Event Made Easy – Block registration to two or more events that have the same category
- I want to allow certain file types on dokan upload files
- Lost Password of my site, how to reset wordpress password?
- Re-use date format on different template