Skip to content

Instantly share code, notes, and snippets.

@gwin
Created February 7, 2017 13:50
Show Gist options
  • Save gwin/c2674b3b7d05e4fe9cfac99071df0a0e to your computer and use it in GitHub Desktop.
Save gwin/c2674b3b7d05e4fe9cfac99071df0a0e to your computer and use it in GitHub Desktop.
<?php
add_shortcode("current_user_id", "current_user_id");
function current_user_id() {
$user = wp_get_current_user();
if( isset( $user->ID ) ) {
return $user->ID;
} else {
return "0";
}
}
// wtedy w wp-admin / Pages w treści strony można wstawić [current_user_id]
// i będzie to wyświetlać id obecnie zalogowanego usera.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment