[wp-hackers] Re: How to redirect to login when filtered posts are empty?

DD32 wordpress at dd32.id.au
Thu Aug 2 01:00:55 GMT 2007


We might be on completely different pages, but heres some code from my  
latest plugin:

add_action('template_redirect','dda_template');
function dda_template($arg){
	global $wp_query;
	if( isset($wp_query->query_vars['ddeviantart']) )
		add_filter('home_template','dda_template_override');
	return $arg;
}
function dda_template_override($template){
	//Override the template for the current page and replace it with our own.
	return dirname(__FILE__).'/dda_portfolio.php';
}


ie. Conditionally add the 2nd filter only if its needed..

On Thu, 02 Aug 2007 10:50:47 +1000, David Coppit <david at coppit.org> wrote:

> On Thu, 2 Aug 2007, DD32 wrote:
>
>> On Thu, 02 Aug 2007 05:38:16 +1000, David Coppit <david at coppit.org>  
>> wrote:
>>> Here's a workable solution:
>>>   - In my filter, set a global if the page should be hidden
>>>   - Use add_action to hook template_redirect
>>>   - In my hook, check to see if the global is set and call  
>>> auth_redirect()
>>>     if it is.
>>>  I wish there was a better way than setting a global, but I don't see  
>>> it.
>>
>> I'm not sure of the code your using, But what i've done was only  
>> register the template_redirect hook IF in the filter its realised as  
>> needing the hook.
>
> Let me make sure I understand... In my filter callback I call add_action
> if I need the redirect. The add_action callback unconditionally calls
> auth_redirect. I also need to call remove_action in the action callback,
> right?
>
> David
>
> _____________________________________________________________________
> David Coppit                           david at coppit.org
> The College of William and Mary        http://coppit.org/
>
> "When the president does it that means that it is not illegal."
> - Richard Nixon on domestic surveillance, 5/19/1977
> "Do I have the legal authority to do this? And the answer is,  
> absolutely."
> - George W. Bush on domestic surveillance, 12/19/2005
> _______________________________________________
> wp-hackers mailing list
> wp-hackers at lists.automattic.com
> http://lists.automattic.com/mailman/listinfo/wp-hackers



-- 
Using Opera's revolutionary e-mail client: http://www.opera.com/mail/


More information about the wp-hackers mailing list