• Hi there,

    I am wondering if someone could take a look at this code and see if I am missing some stuff (which I am pretty sure I am).

    Basically I would like to:
    1) Grab userID
    2) Check to see what url the user is trying to view
    3) Check if user has meta key of ppurl with value of “Yes” – If it finds it than does nothing
    4) if it does not find the meta key for the user it will redirect them.

    Thanks,

    <?php 
    
    	$userinfo = get_userdata(cp_currentUser());
    	$userid = $userinfo->ID;
    
        $currentpage ="https://".$_SERVER['HTTP_HOST'].$_SERVER['REQUEST_URI'];
         if ($currentpage == "https://".$_SERVER['HTTP_HOST']."/category/hot-topic-videos/")
    	 	get_usermeta($userid,'ppurl1');
    	if
    	(ppurl1 == "Yes")
    	{
         die(); //no action
        }
    	else {
    	wp_redirect('https://www.mainsite.com/'); //redirects user to URL
    	}
    	?>
  • The topic ‘Check if my PHP is ok – Thx’ is closed to new replies.