I am creating a plugin and wish to check if the user is logged in the run another function.
This is my first ever plugin and i am still learning how to program at the same time. following I have a simple user conditional, if user is logged in and i am also retrieving data from an array to check if the admin has checked Yes in the plugin options to check for user logged in then execute another function. however I am getting an error Call to undefined function is_user_logged_in()
i think i may need to wrap my conditional in a function and then add an action, can someone please help me. thanks
/* Logged user conditionals */
$logged = get_option('lu_ban_data');
if ($logged['loggedU'] == 'loggedYes' && is_user_logged_in() ) {
lu_ban_detect();
} else {
return false;
}
update Okay I think i managed to get it to work
add_action( 'init', 'lu_user_logged' );
function lu_user_logged() {
$logged = get_option('lu_ban_data');
echo $logged;
if ($logged['loggedU'] == 'loggedYes' && is_user_logged_in() ) {
lu_ban_detect();
} else {
return false;
}
}
is this the proper way?
lu_ban_detect
do?