Community Support Forums — WordPress® ( Users Helping Users ) — 2010-06-23T22:04:15-05:00 http://www.primothemes.com/forums/feed.php?f=4&t=258 2010-06-23T22:04:15-05:00 http://www.primothemes.com/forums/viewtopic.php?t=258&p=1138#p1138 <![CDATA[Re: user id for connection to MySql]]> Statistics: Posted by Jason Caldwell — June 23rd, 2010, 10:04 pm


]]>
2010-06-23T17:28:28-05:00 http://www.primothemes.com/forums/viewtopic.php?t=258&p=1112#p1112 <![CDATA[Re: user id for connection to MySql]]> Statistics: Posted by azulvato — June 23rd, 2010, 5:28 pm


]]>
2010-06-23T17:25:33-05:00 http://www.primothemes.com/forums/viewtopic.php?t=258&p=1110#p1110 <![CDATA[Re: user id for connection to MySql]]> 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

Statistics: Posted by Jason Caldwell — June 23rd, 2010, 5:25 pm


]]>
2010-06-23T17:19:54-05:00 http://www.primothemes.com/forums/viewtopic.php?t=258&p=1109#p1109 <![CDATA[Re: user id for connection to MySql]]> Statistics: Posted by azulvato — June 23rd, 2010, 5:19 pm


]]>
2010-06-23T17:10:26-05:00 http://www.primothemes.com/forums/viewtopic.php?t=258&p=1107#p1107 <![CDATA[Re: user id for connection to MySql]]> Statistics: Posted by Jason Caldwell — June 23rd, 2010, 5:10 pm


]]>
2010-06-23T17:06:58-05:00 http://www.primothemes.com/forums/viewtopic.php?t=258&p=1105#p1105 <![CDATA[Re: user id for connection to MySql]]> Statistics: Posted by azulvato — June 23rd, 2010, 5:06 pm


]]>
2010-06-23T15:44:06-05:00 http://www.primothemes.com/forums/viewtopic.php?t=258&p=1100#p1100 <![CDATA[Re: user id for connection to MySql]]>
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:
<?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

Statistics: Posted by Jason Caldwell — June 23rd, 2010, 3:44 pm


]]>
2010-06-23T15:34:26-05:00 http://www.primothemes.com/forums/viewtopic.php?t=258&p=1097#p1097 <![CDATA[Re: user id for connection to MySql]]>
Code:
$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());

Statistics: Posted by azulvato — June 23rd, 2010, 3:34 pm


]]>
2010-06-23T14:08:14-05:00 http://www.primothemes.com/forums/viewtopic.php?t=258&p=1081#p1081 <![CDATA[Re: user id for connection to MySql]]>
Here is a quick example.
Code:
add_action("init", "my_function");
function my_function(){
    $user = wp_get_current_user();
    print_r($user);
}
 

If $user is false, nobody is logged in.

Statistics: Posted by Jason Caldwell — June 23rd, 2010, 2:08 pm


]]>
2010-06-22T19:21:41-05:00 http://www.primothemes.com/forums/viewtopic.php?t=258&p=1050#p1050 <![CDATA[Re: user id for connection to MySql]]>
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

Statistics: Posted by azulvato — June 22nd, 2010, 7:21 pm


]]>
2010-06-22T00:30:02-05:00 http://www.primothemes.com/forums/viewtopic.php?t=258&p=967#p967 <![CDATA[Re: user id for connection to MySql]]> 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.

Statistics: Posted by Jason Caldwell — June 22nd, 2010, 12:30 am


]]>
2010-06-22T00:25:37-05:00 http://www.primothemes.com/forums/viewtopic.php?t=258&p=966#p966 <![CDATA[Re: user id for connection to MySql]]> 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:
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:
$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:
$user = new WP_User("johndoe22");
echo get_user_option("s2member_subscr_id", $user->ID); 

Statistics: Posted by Jason Caldwell — June 22nd, 2010, 12:25 am


]]>
2010-06-21T22:43:01-05:00 http://www.primothemes.com/forums/viewtopic.php?t=258&p=951#p951 <![CDATA[user id for connection to MySql]]>
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

Statistics: Posted by azulvato — June 21st, 2010, 10:43 pm


]]>