I am trying to access data from some custom fileds in my MySQL db so that I can add them to a webpage that will be printed out. The data is held in a column called “paypal_user” and I need to access one piece of data and print that along with the user id of the user. I’ve had a little help with the code but I am stuck as I am getting the following error:
Call to undefined function get_user_meta()
My code is below. Thanks in advance for any help.
<?php
include_once('wp-config.php');
include_once('wp-load.php');
include_once('wp-includes/wp-db.php');
?>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8" />
<title>Untitled Document</title>
<style type="text/css">
<!-- styling stuff -->
</style>
</head>
<body>
<div id="wrapper">
<div id="top_badge">
<?php
if ( is_user_logged_in() ) {
global $user_ID;
// Get the 'paypal_user' info for the user. Just fetch a single
// value, not an array.
$paypal_user = get_user_meta($user_ID, 'paypal_user', true);
$exp_date = $paypal_user->expire_date;
?>
<div id="member_no_1"><?php echo '$user_ID' ?></div>
<div id="member_lp_1">PR34 2PL</div>
<div id="member_exp_1"><?php echo '$exp_date' ?></div>
</div>
<?php } ?>
</div>
</body>
</html>
For one thing, you don’t have to include wp-config or wp-db when you use wp-load. And as t31os says, single-quotes around variables will keep them from being interpreted by PHP.
Give that a shot. Works for me, assuming that you put this file in the same directory that
wp-load.php
lives in.