我正在使用带有wordpress的strip connect api,我设法建立连接用户的流程,并获取他们的访问令牌和用户ID。但是,我需要以连接到wordpress用户的方式保存它,因为我需要能够回来并稍后引用代码,以便允许正确的人获得报酬。我写了添加了几行add_user_meta()但我的var_dump()出来了null。这是一些代码:
global $wpdb;
$table = $wpdb->prefix."stripe_connect";
$wpdb->insert($table , array(
'time' => current_time('mysql'),
'access_token' => $token,
'stripe_publishable_key' => $key,
'stripe_user_id' => $userid)
);
$user_ID = get_current_user_id();
add_user_meta($user_ID, ‘stripe_userid’, $userid, $unique);
add_user_meta($user_ID, ‘stripe_token’, $token, $unique);
$stripeuserid = get_user_meta($user_ID, 'stripe_userid', true);
var_dump($stripeuserid);
$response = '<h4>Thank you for connecting with Stripe. This information has been saved in the database and can be viewed in the Admin Panel.</h4>';
答案 0 :(得分:0)
我明白了,它与我添加数据的方式无关。问题在于检索它。 这修好了它:
$user_ID = get_current_user_id();
update_user_meta($user_ID, ‘stripe_userid’, maybe_serialize( $userid ));
add_user_meta($user_ID, ‘stripe_token’, $token, $unique);
$stripeuserid = get_user_meta($user_ID, 'stripe_userid');
var_dump($stripeuserid);