I’ve built a custom user account system using a custom post type. I was wondering whether it is safe to use the built-in function wp_set_auth_cookie($user_id, $remember, $secure)
WordPress uses for the built-in user system. For $user_id
I figured I could use the post id. But wouldn’t this clash with the existing system? Is there a nifty trick to keep the default user cookies from clashing with the custom user cookies or shouldn’t I use this function at all?
1 comment
Comments are closed.
Why are you building a seperate user system in the first place? The wordpress builtin system is pretty flexible.
In theory all the login functions like wp_set_auth_cookie(), wp_generate_auth_cookie(), wp_parse_auth_cookie() etc. are all pluggable functions. Which means you can replace them with your own custom functions.
But to be realistic, it will be a lot of work to get this working as you won’t be able to use the default
wp_set_auth_cookie()
as long as you replace all login functions, or sync your virtual userbase with the realwp_users
table.The default function will not set a valid login cookie unless it finds that
$user_id
is a real wordpress user.I think your best options are:
store your custom stuff in user_meta.