CF7 get_current_user_id() not working in filter
-
I’m trying to get the logged-in user information (current user id) inside a CF7 filter like this:
function wpcf7_preload($tag, $unused) {
$user_id = get_current_user_id();
// do something with $user_id…
return $tag;
}
add_filter( ‘wpcf7_form_tag‘, ‘wpcf7_preload’, 10, 2);Doesn’t matter if the a user is logged in or not, $user_id always is 0! Same problem inside the “wpcf7_before_send_mail” filter.
On the other hand the form tag “user_login” and “user_id” work as desired. Does anyone know, why “get_current_user_id()” does not work?
Viewing 2 replies - 1 through 2 (of 2 total)
Viewing 2 replies - 1 through 2 (of 2 total)
- The topic ‘CF7 get_current_user_id() not working in filter’ is closed to new replies.