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
- Add 2 links in between the navigation using the Breadcrumb Navxt plugin hook
- Simple ajax request with Vanilla JS keeps given 400 Bad Request
- How to create TEMPORARY Download links in a wordpress POST?
- Conditionally add apt. Open Graph meta data to different pages on WordPress site
- PHP Fatal error: Call to undefined function plugin_basename
- plugin development: problem with functions
- How do i login when i cant access wp-login.php?
- add_query_arg not working
- WooCommerce get_price returning wrong price when used via ajax
- Is there a way I can find wordpress posts that don’t contain a word?
- Prevent shortcode from being wrapped in tags
- How to Use Parameters with a Do_Action Function Within PHP Tags
- Dropdown menu on custom page with product to choose number of products per page
- How do action and filter hooks understand where to look for the core function that we hooked our function to them
- Why is my staging subdomain not sending wordpress_logged_in cookies?
- Change wordpress current_time function to different timezone
- Inserting HTML tag with ACF into shortcode
- WordPress filter that hook after each action/filter hook
- When to use action hooks and plugins
- Simple ajax call not working in wordpress plugin
- Single central login for front end users from any site
- Executing my function once on a specific time
- How to append to title via functions.php for auto-posting plugin [duplicate]
- Get posts from WP_Query and format them on admin_head
- Missing Argument
- load_plugin_textdomain error
- Automatically add attributes to woocommerce product?
- How to override a plugin function wrapped in a class?
- Bootstrap Drop Down menu is not working
- How to Display a Plugin function (content) on frontpage using index.php
- Any hook for pre-plugin-update -either bulk or single plugin update
- Form isn’t inserting data into database with ajax plugin
- Insert new user with form submit ‘init’ hook
- Theme my Login plugin, how to update fields
- Edit Yoast SEO breadcrumbs output [closed]
- What’s the best way to implement AJAX in WordPress?
- How to Create a Custom Panel and Fields in Post Page [Plugin]
- Adding Shortcode to Text Widget
- Date calculations from 2 custom fields
- How to put JQuery/Ajax inside shortcode?
- When to load auto-login code?
- AJAX search posts and pages
- Snippets: is it better to add them in functions.php or make site-specific plugins?
- WordPress Ajax Posting from App
- How can I force users to a particular subdomain to log in for MU (Multisite)?
- Does WordPress validate inputs to all functions? (such as get_user_meta and insert_user_meta)
- Plugin: Google Analytics for Dashboard error – Timestamp is too far from current time
- Custom random quote widget breaks when used in multiple sidebars
- “Request has expired” with “Make your site social” (Gigya) plugin
- How to get all of the activate_plugin action parameters?
- __callStatic method handler passed to add_action causes bug in PHP
- Using a function to change favorites listing
- Using a custom plugin to capture input data via Ajax and PHP