Fires in between the time after WordPress core has finished loading but before any headers are sent.

learn more… | top users | synonyms

1
vote
1answer
23 views

Plugins rewrite rules the right way

I need to create rewrite rules for my plugin. This plugin will be running on a very large WordPress Network (+2000 sites) so performance is important. Most tutorials and the codex recommend to ...
1
vote
0answers
49 views

Init plugin again after ajax call finish

We have this website that the navigation between pages work with ajax. in the blog page we use this great plugin to make the ajax load-more posts. all works great but the problem is that when you ...
0
votes
0answers
33 views

Function Hooked on Init Running Multiple Times

I have a method that logs the users login time. public function log_login() { if ( isset($_COOKIE['current_visit']) ) { return; } // Get current user $user = ...
0
votes
3answers
40 views

Action 'init' function doesn't return variable

I have a function which checks if $_POST is set (a form which submits to the same page). I need to have it initialized before the page is loaded because the function will do a header redirect if the ...
0
votes
1answer
40 views

What is the entry point of a WordPress theme?

When WordPress is loading and the theme is parsed, which file is loaded first? Is it one of the template hierarchy members or is it functions.php? Are there exceptions to the load order of files in ...
0
votes
0answers
26 views

Can I use a hook other than 'init' to handle form submissions?

I'm developing a plugin that handles form submissions at several different points. As such, I was relying on being able to use global $post and get_query_var to determine which stage the user is at ...
0
votes
1answer
112 views

add_action in a custom plugin

I did a plugin to create a when the cookie is FALSE. Actually, the was working, but when I was about to create the cookie, it said that my header was already sent. Then, I had the code ...
0
votes
1answer
24 views

API calls on plugin activation or init?

When I activate my plugin, I need to call an API, to get some items, lets say fruits, flowers and animals. I need to create taxonomy terms out of these items. Then I need to loop over these items and ...
1
vote
0answers
42 views

Best action hook to create custom post and assign taxonomy terms to it on plugin activation?

When I install the plugin, I want to create 10 CPTs of a particular type, which I define in the init action hook, and want to assign 10 terms of a custom taxonomy, which too is defined in an init ...
0
votes
1answer
57 views

Custom setting field value not working inside add_action init hook

I have added custom setting options page under WordPress settings and those are working perfectly. I have tested their values also. But when I am using those values inside function file within ...
1
vote
0answers
81 views

Fire on widgets_init only on dashboard

I have an interesting issue. I need to launch an action on widgets_init, but ONLY on the WordPress Dashboard. So I can't use dashboard related hooks, because they fire too late; it has to be on ...
0
votes
2answers
57 views

Can i use init hook for API purpose?

My question title might be little confuse. Here is the scenario, For example: I am giving an API service from my wordpress site. Using it others can know few information. Like if they send a User ID ...
0
votes
0answers
242 views

update_post_meta returning false when called during init

Given a custom URL like: http://clientsite.com/tvt?pmc_task=member_check&post_id=1041&user=3851&status=approved I'm trying to catch the URL and add the user_id to a custom post meta ...
0
votes
1answer
392 views

WordPress Plugin Boilerplate - add_action hook in static “activate” function

I'm hoping someone can point me in the right direction here. I'm using the Wordpress Plugin Boilerplate to develop a custom plugin. On install, the plugin will register a new post type (course), a ...
0
votes
1answer
59 views

Plugin init hook fires repeatedly

I 've just noticed that the init event of a plugin I write myself keeps firing every minute or so if any dashboard's page is loaded in the browser, without interacting with it or even focus on it. Is ...
0
votes
0answers
99 views

$wpdb->insert running multiple times?

Im trying to run a $wpdb->insert ONCE on every page load (for testing purposes). The insert will insert a meta field for a post type. I have tried hooking the insert function into "init", add it to ...
0
votes
1answer
205 views

Why doesn't global $wp_query not get hooked?

I have a plugin that helps me to make lazy loading on posts of a custom post type. The idea is to add an action to the template_redirect/init and get data from the global $wp_query to make jquery ...
0
votes
1answer
90 views

How to translate Widget Description in constructor?

I'm building a localized widget and the translation works everywhere but in the language string in the constructor. I have read that the whole plugin initialisation has to be bound to the init ...
0
votes
0answers
256 views

Hooking action once but called twice

class GridModSidebars{ public function init(){ add_action('widgets_init', array($this, 'registerSidebars'),20); } public function registerSidebars(){ $args = array( 'name' ...
1
vote
0answers
132 views

Get log of function/method calls made by do_action() on WordPress initialization

Is there any way I can get a log of the method calls that are made when do_action( 'init') is fired?
1
vote
0answers
63 views

PHP header() gives headers already sent

I am working on a checkout proces in Wordpress where if customer clicks on the checkout button he gets redirected to a payment provider. Important to know: I use a session in this proces. I use PHP ...
0
votes
0answers
114 views

Init hook for header send

I am working on a checkout proces where if I submit the checkout I get an error "headers already send" because I use a PHP header() function to send the customer to my payment provider url. My idea ...
0
votes
2answers
70 views

Basic function call on init failing

I've been banging my head against this for a while. I have this very straight-forward code in my plugin: add_action('init', 'register_shortcodes'); $shortcodeRegistrationRan = False; function ...
-1
votes
1answer
46 views

Why do I need to register my custom post type a second time when flushing rewrite rules?

If I register my custom post type when the init action fires (which is before plugin activation) why do I need to register my custom post type a second time when flushing rewrite rules (on plugin ...
0
votes
1answer
135 views

Init hook function to call other hook in function.php

I am trying to add a function in the init hook that will call another hook like this : add_action( 'init', 'loadAfterUserRegistrationHook' ); function loadAfterUserRegistrationHook(){ ...
1
vote
0answers
137 views

Post submit using shortcode and init

I'm trying to find the best way to return errors to a page once a form submitted by using a shortcode. I'm adding a function to init such as - add_action( 'init', 'contact_form_process_post' ); ...
2
votes
1answer
320 views

add_feed and flush_rewrite_rules

There seems to be quite a controversial opinion on the WordPress flush_rewrite_rules() function. According to the Codex, it is highly discouraged to use this function on the init action hook. ...
0
votes
1answer
164 views

Best hook for a function which adds shortcodes to the system?

I have a plugin released, and one of my customers was reporting a problem where the plugin was outputting ads in the header area of their website. I have a function defined which contains my ...
1
vote
1answer
477 views

Form Shortcode not saving data to WP database

I'm developing a plugin that creates a custom table upon plugin activation. The plugin allows users to add a form shortcode to collect data for leads. I've got to the point where either the data ...
1
vote
2answers
1k views

How to setcookie if is_page('page') ? should I use add_action('init') or there is another action?

I want to setcookie if is_page('arabic') or is_page('english') then redirect to home_url() only if the page name/slug arabic or english, I think that init action happen before the code determine the ...
1
vote
1answer
750 views

Problem with is_page & wp_redirect

I use cookies to determine which menu I should use on my website. This is working fine, but I want to force the correct one if someone views the URL directly instead of via the URL with a query string ...
0
votes
0answers
1k views

do_action( 'init' ) in wp-settings.php breaks my website. All plugins and themes disabled

As the title says, do_action( 'init' ) in wp-settings.php breaks my website. All plugins and themes have been disabled. Basically if I comment out line 308 which is simply do_action( 'init' ); then ...
0
votes
0answers
148 views

add_action not working in header?

i need to enable the session variables to my theme , so i have the following code in my theme functions.php function session_manager() { if (!session_id()) { session_start(); // Get ...
0
votes
0answers
442 views

Front end form submission/processing, without using a template file

I'm writing a plugin which has a front end form that is generated by a shortcode. I'm struggling with processing the form submission in any way. Many tutorials describe placing form processing code at ...
1
vote
1answer
273 views

Load ajax if is_home()

I want to show some simple things on homepage with ajax. The problem is I want to load everything when is_home() is true. Php, js, everything. In funtions.php: add_action('init', ...
0
votes
1answer
69 views

How to do a task only once for logged in users

I want to do a task only once after an user has visited my site. I am currently doing like this: function my_task(){ //do my tasks } add_action('init', 'my_task'); I am doing this from a ...
1
vote
3answers
2k views

WordPress Theme activation hook?

I know the many tricks to see if said theme is activated, I have scoured the internet. I am not looking for re-pasting of that code. What I am looking for though is weather or not 3.3-3.5 released a ...
1
vote
1answer
61 views

Stop WordPress Entirely and Run My Own Code

I have a site that must be deployed in a WP Multisite environment but none of the code in the site uses WordPress at all. How can I intercept WordPress, perhaps at 'init', and tell it to stop doing ...
2
votes
3answers
2k views

Using get_terms for custom taxonomy in functions.php

I`m trying to retrieve the names of taxonomy items and include them into a theme admin panel. function retrieve_my_terms() { global $terms; $terms = get_terms('taxonomy'); foreach ...
9
votes
2answers
7k views

Use wp init hook to call other hooks?

I want to know if it is a good practice according to WordPress theme or plugin development. add_action('init','all_my_hooks'); function all_my_hooks(){ // some initialization stuff here and then ...
0
votes
1answer
303 views

Developing plugin, where to place action hooks etc?

I am dividing my plugin code into multiple files and functions. When I have a function and straight after it an action hook, or for example add_shortcode, should that line go straight after the ...
4
votes
1answer
703 views

When we register a custom taxonomy or post type, does the WP database modified at all?

When you use the register post type and register taxonomy functions in your functions.php, where do all that setting info get stored in regards to the CT's and CPT's you are registering? I'm talking ...
0
votes
2answers
3k views

IE 9 Clears Form Fields

This is a really strange issue that I cannot seem to solve. I have several forms (login, registration, and other) outputted on a site via short codes. When the forms are submitted, their data is ...
1
vote
2answers
2k views

Change page title from plugin

Is possible to change page title on the fly from plugin? I've try global $post, but seem like plugin runs after. Any Ideas? Edit: Im writting some pages on the fly, based on same page / post, so ...
-1
votes
1answer
85 views

theme or plugin or server is outputting html before the init hook fires, how is it possible to prevent this

I have a plugin that detects the useragent of a request made during the init hook and if it matches my desired value, I set a flag so that my own xml content is sent during the found_posts filter ...
0
votes
2answers
796 views

Are there any action like 'init_frontend'

I've found init and init_admin. Are there any action that executes just in the frontend? Thanks.
-1
votes
1answer
1k views

plugin: 'init' hook, check if we're not in admin

I've tried this inside of my plugin ('init' hook) but it doesn't work: if(is_front_page() || is_singular() || is_archive()) { ... } How could I check it using init hook? Thanks.
8
votes
1answer
5k views

What is the very earliest action hook you can call?

After the solution to this question was to get a function to launch BEFORE the init action is fired by taking the sequence out of its function, it got me thinking, is there any earlier in the WP load ...
0
votes
1answer
183 views

Preset Widgets ONLY after site is initially created

I want to preset some widgets using functions included in my theme ONLY after a site is initially created (my theme is the default for all new sites in my instance of WordPress). I DO NOT want my ...
4
votes
1answer
5k views

Difference between after_setup_theme and init action hooks?

What is the difference between the after_setup_theme and init action hooks? It seems they are both called right before any page in WordPress is loaded (even admin pages).