0

I'm looking to find a way to check if the author has included their first name (at registration) and if they haven't then do something... I have no idea where to start, or finish, but I assume it looks a little like this???

<?php if (get_the_author_meta('first_name', true)) { ?>
// do something
<?php } ?>
1

The second parameter for get_the_author_meta is the user iD.

If you're using the function within the loop, the user ID would be the ID of the current user if not you would have to specify the user ID.

if ( !get_the_author_meta('first_name', $user_id )) {
    // do something
}
  • How would I apply that same check to the current logged in author? – Pete Dec 23 '16 at 8:12
  • 1
    To apply this to the current user,your $user_id = get_current_user_id() – Tunji Dec 23 '16 at 8:16

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.