PriMoThemes — now s2Member® (official notice)

This is now a very OLD forum system. It's in READ-ONLY mode.
All community interaction now occurs at WP Sharks™. See: new forums @ WP Sharks™

user id for connection to MySql

s2Member Plugin. A Membership plugin for WordPress®.

user id for connection to MySql

Postby azulvato » June 21st, 2010, 10:43 pm

Hello,

First off what a great plug-in. I have forms on my membership site that when members save data to MySql need to be only accessible by these members.

I need to be able to link to the user id in the wordpress tables,
to know the php variable that wordpress uses for the user Id so
I can make it the same type as the user ID in your table.

when I enter a value into php, I have to name it so php knows what to do with it.
Like $test_id

I have to be able to tell who is logged in, so I can put that id into the MySql database
when they enter the info in the form.

Also so I can sort the database to show only their data when they are browsing the
data they stored there.

I'm not sure how to access that information from the s2Member plugin.


Any help is greatly appreciated as this is one of my final hurdles to going live.
Thank You Very Much,
Mike Ocampo
User avatar
azulvato
Registered User
Registered User
 
Posts: 6
Joined: June 14, 2010

Re: user id for connection to MySql

Postby Jason Caldwell » June 22nd, 2010, 12:25 am

Hi Mike. Thanks for your inquiry. I'm not sure I completely understand your question,
but let's break this down a bit, and hopefully this will help you out.


s2Member uses existing MySQL tables that are already a part of WordPress. So the user ID, is the same as any WordPress User would have. The ID is found in the `wp_users` table, in the `ID` column.

Now, additional information is also stored for each User/Member, and again, the storage of this information follows existing WordPress standards. User/Member details are stored in the `wp_usermeta` table, referenced by the `user_id` column, matching the `ID` column in the `wp_users` table.

Now, here is a list of meta keys found in the `wp_usermeta` table with respect to s2Member.

`wp_usermeta`.`meta_key` = `s2member_custom`
This is the custom string that you passed through the PayPal Button/Form, inside your Shortcode. By default, this will just be the domain name of your site. Although sometimes additional data is pipe delimited by a site owner or developer that is integrating s2Member in more creative ways.

`wp_usermeta`.`meta_key` = `s2member_subscr_id`
This is a paid Subscription ID, referencing a recurring payment profile, or a PayPal subscription, or a PayPal transaction that is associated with a specific Member's account.

`wp_usermeta`.`meta_key` = `s2member_subscr_gateway`
This is a paid Subscription Gateway code. Normally one of these values:
paypal, alipay, authnet, clickbank, google, or ccbill.


`wp_usermeta`.`meta_key` = `s2member_custom_fields`
This is an array of Custom Fields, if there are any, as configured by the site owner. The array is associative, with each key being a match to the "ID" of the Custom Field, as configured under s2Member -> General Options -> Custom Fields.

`wp_usermeta`.`meta_key` = `s2member_file_download_access_log`
This is an associative array, containing a history of file downloads that have occurred for each Member. This will only hold x days worth of data, and then it is rotated automatically into `s2member_file_download_access_arc`.

`wp_usermeta`.`meta_key` = `s2member_auto_eot_time`
This is a timestamp, that is NOT always filled. It is only used under certain conditions that require it. That being said, when it is set, this is used by s2Member's Auto EOT System, which works to demote/delete accounts after they have expired. EOT = End Of Term.

`wp_usermeta`.`meta_key` = `s2member_last_payment_time`
This is a timestamp, that is NOT always filled.
It's only available once a payment has been received.


`wp_usermeta`.`meta_key` = `s2member_paid_registration_times`
This is an associative array of Paid Registration Timestamps.
Marking the first time a Member reached each paid Membership Level.


Now. Let's say you wanted to find the Subscr. ID for an existing Member. First, you need their User ID. Let's say we are dealing with User ID# 123. Here is how you would do that if they are currently logged in.
Code: Select all
echo get_user_option("s2member_subscr_id"); 

Or, if you're running routines silently in a cron job, or need to pull information for a User/Member that is not the User/Member currently logged into the site. Here is how you do that.
Code: Select all
$user = new WP_User(123);
echo get_user_option("s2member_subscr_id", $user->ID); 

If you need to pull information based on a Username, instead of the ID, you can do this:
Code: Select all
$user = new WP_User("johndoe22");
echo get_user_option("s2member_subscr_id", $user->ID); 
~ Jason Caldwell / Lead Developer
& Zeitgeist Movie Advocate: http://www.zeitgeistmovie.com/

Is the s2Member plugin working for you? Please rate s2Member at WordPress.org.
You'll need a WordPress.org account ( comes in handy ). Then rate s2Member here Image
.
User avatar
Jason Caldwell
Lead Developer
Lead Developer
 
Posts: 4045
Joined: May 3, 2010
Location: Georgia / USA

Re: user id for connection to MySql

Postby Jason Caldwell » June 22nd, 2010, 12:30 am

In WP 3.0+, the use of `get_usermeta()`, has been deprecated.
Instead, use `get_user_meta()`, only in WP 3.0+.


Starting with s2Member v3.3.2+, please use get_user_option().
I updated the post above to reflect this change.
~ Jason Caldwell / Lead Developer
& Zeitgeist Movie Advocate: http://www.zeitgeistmovie.com/

Is the s2Member plugin working for you? Please rate s2Member at WordPress.org.
You'll need a WordPress.org account ( comes in handy ). Then rate s2Member here Image
.
User avatar
Jason Caldwell
Lead Developer
Lead Developer
 
Posts: 4045
Joined: May 3, 2010
Location: Georgia / USA

Re: user id for connection to MySql

Postby azulvato » June 22nd, 2010, 7:21 pm

Jason Caldwell wrote:In WP 3.0+, the use of `get_usermeta()`, has been deprecated.

Instead, use `get_user_meta()`, only in WP 3.0+.


thank you for a speedy reply, but i can't seem to get wp_get_current_user() to work.

I am creating a membership site where members can save text in fields. I need these to be assigned to this member for retrieve at a later time. This information is to be available only to the person who saved it. I have wp 3.0
User avatar
azulvato
Registered User
Registered User
 
Posts: 6
Joined: June 14, 2010

Re: user id for connection to MySql

Postby Jason Caldwell » June 23rd, 2010, 2:08 pm

Where are you calling upon this function?

Here is a quick example.
Code: Select all
add_action("init", "my_function");
function my_function(){
    $user = wp_get_current_user();
    print_r($user);
}
 

If $user is false, nobody is logged in.
~ Jason Caldwell / Lead Developer
& Zeitgeist Movie Advocate: http://www.zeitgeistmovie.com/

Is the s2Member plugin working for you? Please rate s2Member at WordPress.org.
You'll need a WordPress.org account ( comes in handy ). Then rate s2Member here Image
.
User avatar
Jason Caldwell
Lead Developer
Lead Developer
 
Posts: 4045
Joined: May 3, 2010
Location: Georgia / USA

Re: user id for connection to MySql

Postby azulvato » June 23rd, 2010, 3:34 pm

Code: Select all
$oto_name= $_POST['oto_name'];
$oto_html = AddSlashes($_POST['oto_html']);
$member_id = [color=#FF0000]wp_get_current_user();
[/color]
mysql_connect("localhost", "user", "password") or die(mysql_error());


mysql_select_db("db name here") or die(mysql_error());


mysql_query("INSERT INTO new_oto (oto_name, oto_html) VALUES ('$oto_name', '$oto_html') ")
      or die(mysql_error());
User avatar
azulvato
Registered User
Registered User
 
Posts: 6
Joined: June 14, 2010

Re: user id for connection to MySql

Postby Jason Caldwell » June 23rd, 2010, 3:44 pm

Ok, my guess is that you're trying to call upon WordPress functions, outside of the WordPress framework. You'll want to integrate whatever script your're writing into the WordPress framework first.

Also, you'll probably want to read up on the wpdb Class:
http://codex.wordpress.org/Function_Ref ... wpdb_Class

So this example, would go inside a WordPress plugin file:
/wp-content/mu-plugins/my-plugin.php

Code: Select all
<?php
add_action
("init", "my_function");
    function my_function(){
        $user = wp_get_current_user();
        print_r($user);
    }
?>

See: http://codex.wordpress.org/Writing_a_Plugin
~ Jason Caldwell / Lead Developer
& Zeitgeist Movie Advocate: http://www.zeitgeistmovie.com/

Is the s2Member plugin working for you? Please rate s2Member at WordPress.org.
You'll need a WordPress.org account ( comes in handy ). Then rate s2Member here Image
.
User avatar
Jason Caldwell
Lead Developer
Lead Developer
 
Posts: 4045
Joined: May 3, 2010
Location: Georgia / USA

Re: user id for connection to MySql

Postby azulvato » June 23rd, 2010, 5:06 pm

k let me grab my speedo and dive in tyvm
User avatar
azulvato
Registered User
Registered User
 
Posts: 6
Joined: June 14, 2010

Re: user id for connection to MySql

Postby Jason Caldwell » June 23rd, 2010, 5:10 pm

I hear you. Good luck!
~ Jason Caldwell / Lead Developer
& Zeitgeist Movie Advocate: http://www.zeitgeistmovie.com/

Is the s2Member plugin working for you? Please rate s2Member at WordPress.org.
You'll need a WordPress.org account ( comes in handy ). Then rate s2Member here Image
.
User avatar
Jason Caldwell
Lead Developer
Lead Developer
 
Posts: 4045
Joined: May 3, 2010
Location: Georgia / USA

Re: user id for connection to MySql

Postby azulvato » June 23rd, 2010, 5:19 pm

do you have a skype?
User avatar
azulvato
Registered User
Registered User
 
Posts: 6
Joined: June 14, 2010

Re: user id for connection to MySql

Postby Jason Caldwell » June 23rd, 2010, 5:25 pm

Sorry bud. I only provide support here for our own products, not for general WordPress development.
You can post this question in the General WordPress development forum, and see if anyone else here can help you. There are lots of friendly folks here: viewforum.php?f=13
~ Jason Caldwell / Lead Developer
& Zeitgeist Movie Advocate: http://www.zeitgeistmovie.com/

Is the s2Member plugin working for you? Please rate s2Member at WordPress.org.
You'll need a WordPress.org account ( comes in handy ). Then rate s2Member here Image
.
User avatar
Jason Caldwell
Lead Developer
Lead Developer
 
Posts: 4045
Joined: May 3, 2010
Location: Georgia / USA

Re: user id for connection to MySql

Postby azulvato » June 23rd, 2010, 5:28 pm

thnx will do when I run into snags
User avatar
azulvato
Registered User
Registered User
 
Posts: 6
Joined: June 14, 2010

Re: user id for connection to MySql

Postby Jason Caldwell » June 23rd, 2010, 10:04 pm

Ok, thanks. I'll try to post as much information in the forums as I can.
~ Jason Caldwell / Lead Developer
& Zeitgeist Movie Advocate: http://www.zeitgeistmovie.com/

Is the s2Member plugin working for you? Please rate s2Member at WordPress.org.
You'll need a WordPress.org account ( comes in handy ). Then rate s2Member here Image
.
User avatar
Jason Caldwell
Lead Developer
Lead Developer
 
Posts: 4045
Joined: May 3, 2010
Location: Georgia / USA


Return to s2Member Plugin

Who is online

Users browsing this forum: Google [Bot] and 1 guest

cron