• Resolved woernib

    (@woernib)


    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)
  • Plugin Author Takayuki Miyoshi

    (@takayukister)

    Where can we see the website in question?

    Thread Starter woernib

    (@woernib)

    Sorry Takayuki, I was about to prepare a link with the error example when I found that the function “get_current_user_id()” works now! I don’t know why, but everything seems perfect again now. Thank you for your quick response!

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.