[wp-hackers] getting user_id in buddypress profile page
abdussamad at abdussamad.com
Sun Oct 6 23:19:59 UTC 2013
In the below code the first argument has to be a string so you should
put the table name in quotes. Also use $wpdb->prefix to refer to the
table prefix instead of "wp_" because this is something that can be
changed when installing wordpress and varies in multi site installs.
$wpdb->insert(wp_jo_plugin_options, array (
'user_id' => $userid,
'length' => $_POST['length'],
'girth' => $_POST['girth'],
'date' => $_POST['date'],
If you want to use the global variable $current_user why call
Finally there is this:
"Use the init or any subsequent action to call this function. Calling
it outside of an action can lead to troubles. See #14024 for details. "
On 10/06/2013 04:22 AM, BenderisGreat wrote:
> This is likely very simple, but I am having an issue with it.
> I am using
> global $wpdb, $userdata, $current_user;
> $current_user = wp_get_current_user();
> $userid = $current_user->ID;
> I can echo out $userid and it shows the correct user ID, but when I put it
> into the form submit;
> $wpdb->insert(wp_jo_plugin_options, array (
> 'user_id' => $userid,
> 'length' => $_POST['length'],
> 'girth' => $_POST['girth'],
> 'date' => $_POST['date'],
> it just posts a 0 to the database. Am I doing something wrong here? It
> seems very straight forward, never had an issue with such a simple task.
> But trying to add this code to buddypress is a real hassle.
> View this message in context: http://wordpress-hackers.1065353.n5.nabble.com/getting-user-id-in-buddypress-profile-page-tp42444.html
> Sent from the Wordpress Hackers mailing list archive at Nabble.com.
> wp-hackers mailing list
> wp-hackers at lists.automattic.com
More information about the wp-hackers