[wp-hackers] Auto creating custom menu

Christian Wach needle at haystack.co.uk
Thu Nov 17 14:58:03 UTC 2011


Hi Tom,

On 17 Nov 2011, at 14:33, Tom Barrett wrote:

> The problem is that it won't add the pages to the menu, unless I am  
> logged in. Most likely this is me falling foul of the 'edit_posts'  
> capability again.

Then how about forcing a login before you call  
do_action( 'setup_wordpress' )?
Something like...

$user = get_userdatabylogin( $username );
if ( is_object( $user ) ) {
   // login procedure
   wp_set_current_user( $user->ID, $username );
   wp_set_auth_cookie( $user->ID );
   do_action( 'wp_login', $username );
}

Cheers,

Christian



More information about the wp-hackers mailing list