• Hello Guys,

    im struggeling with getting the current post object in the filter “option_active_plugins”. The gloabls for $wp_query, $post,… are not set at the time the filter is called. So while WordPress needs to set them based on some data too, I was wondering how one would get the current context before the $wp_query is set (which therefore makes most of the relevant wordpress functions unusable).

    Note: Im running the filter function in a mu-plugin, so it get’s called early enough. I thought this wouldn’t be a problem. Also the documentation on the “option_<name>” filters has example code using wp_query functions. What makes my filter so special?

    Here is the register code, loaded in a mu-plugin:

    
    function pr_disable_plugin_routine($plugins)
    {
    	global $wpdb,/*set*/
            $wp_query; /*not set*/
    	
            ...
    
    	return $plugins;
    }
    add_filter( 'option_active_plugins', 'pr_disable_plugin_routine' );

    I’ve allready tried every global I could imagine, to at least grab an id from an index.php redirect or something like that. No solution so far.

    Thanks in advance

Viewing 1 replies (of 1 total)
  • Thread Starter ColdJackle

    (@coldjackle)

    EDIT: Couldn’t find the edit-button, sorry ??

    The tags are wrong, I hit enter to early. Also Id’ like to add, that it’s not explicit the post object that I need, more of the current context or some data to work with. I’d like to know what site the user is on, without reparsing the whole url (which also doesn’t work with the functions i tried, like “url_to_postid”).

Viewing 1 replies (of 1 total)
  • The topic ‘Get Post Object before $wp_query is set’ is closed to new replies.