Quantcast
Channel: WordPress.org Forums » All Posts
Viewing all articles
Browse latest Browse all 112696

Middle8Media on "if user is logged in AND a custom field exists."

$
0
0

Thanks.

I am not sure if this is overkill or bloated code, but I ended up going with this code.

I search for the current user, check to see if they are logged in, then return their i, then check to see if their custom field exists. if empty, I echo no html, if it does exist, I echo desired html.

global $current_user;
get_currentuserinfo();
$author_id = $current_user->ID;
$film_custom_field = get_field('film_1', 'user_' . $author_id );
if ( is_user_logged_in() && empty( $film_custom_field ) ) {
echo ' ';
} else {
echo 'html goes here';

}


Viewing all articles
Browse latest Browse all 112696

Trending Articles