snubbr.com

Verisign SSL for sub-domain pointed at another website?

Get a Verisign SSL certificate for 30 days FREE. Click here to use coupon...

Get a free trial of Verisign SSL certificates. Click here for this special deal...
First of all Verisign SSL for sub-domain pointed at another website? Thanks in advance for any comment. Second question.. I have the contribution "home or business customer" installed. I am going to to modify it to where the customer automatically gets signed up as a home customer, and only the admin (me) can change their status to a business customer. This will allow me to add authorized resellers of my products to the store. I have a few already so I'd like to complete this asap..

My question is as follows. I would like to modify the account.php page for resellers only (business customers only) so when a reseller logs in, it will show certain tables that the original does not show, 'sales', 'add new customer', etc. How do I look into the database to see who is logged in? I want a statement like this:.

If currentuser is business {.

Echo "whatever".

}.

I am familiar with PHP, but I'm not sure exactly what to use here. Any help is appreciated!..

Comments (13)

Good question... I dunno what is the right answer to your question. I'll do some research in Google and get back to you if I find an decent answer. You should email the people at Verisign as they probably can answer it..

Comment #1

OK another question. I want to use this in another section. I'm wanting to call up the type of customer (home or business) in admin/customers.php so I can easily see what they are without clicking edit for each customer. Here's what I have been running in to....

<?php.

$customers_type = tep_db_query("select customers_usertype from customers");.

Echo $customers_type;.

?>.

The result here is resource id #.... I've searched on this and found only that I need to add a fetch_array statement in there... so I have this:.

<?php.

$customers_type = tep_db_query("select customers_usertype from customers");.

$type = tep_db_fetch_array($customers_type);.

Echo $type;.

?>.

The result is "array". Can anyone offer some light on this?..

Comment #2

Ok, one question at a time...

In.

Account.php.

Locate this code block:.

If (!tep_session_is_registered('customer_id')) {.

$navigation->set_snapshot();.

Tep_redirect(tep_href_link(FILENAME_LOGIN, '', 'SSL'));.

}.

And after it place:.

$customer_usertype_query = tep_db_query("select customer_usertype from "TABLE_CUSTOMERS" where customers_id = '"(int)$customer_id"'");.

$customer_usertype = tep_db_fetch_array($customer_usertype_query);.

The variable $customer_usertype['customer_usertype'] now contains the database value for the logged in customer, so you can use a simple if statement..

If($customer_usertype['customer_usertype'] == "b") {.

// echo stuff here.

}..

Comment #3

The easiest way to do this is set a default value for your "usertype" field in your customers table. If you know your way around phpMyAdmin then simply set the default value of the appropriate field to "h"..

Alternatively, we can use the SQL query in the.

Create_account.php.

To always set this for us..

In.

Create_account.php.

Locate this code block:.

$sql_data_array = array('customers_firstname' => $firstname,.

'customers_lastname' => $lastname,.

'customers_email_address' => $email_address,.

'customers_telephone' => $telephone,.

'customers_fax' => $fax,.

'customers_newsletter' => $newsletter,.

'customers_password' => tep_encrypt_password($password));.

And replace it with:.

$sql_data_array = array('customers_firstname' => $firstname,.

'customers_lastname' => $lastname,.

'customers_email_address' => $email_address,.

'customers_telephone' => $telephone,.

'customers_fax' => $fax,.

'customers_newsletter' => $newsletter,.

'customers_password' => tep_encrypt_password($password),.

'customers_usertype' => 'h');.

The "customers_usertype" field will now always be set to "h" when a new account is created. You don't need to place any extra fields into the create account form...

Comment #4

I assume you mean you want to display their account type on the right hand panel when selected? Easy enough...

In.

Admin/customers.php.

Locate this line:.

$customers_query_raw = "select c.customers_id, c.customers_lastname, c.customers_firstname, c.customers_email_address, a.entry_country_id from "TABLE_CUSTOMERS" c left join "TABLE_ADDRESS_BOOK" a on c.customers_id = a.customers_id and c.customers_default_address_id = a.address_book_id "$search" order by c.customers_lastname, c.customers_firstname";.

And replace it with:.

$customers_query_raw = "select c.customers_id, c.customers_lastname, c.customers_firstname, c.customers_email_address, c.customers_usertype, a.entry_country_id from "TABLE_CUSTOMERS" c left join "TABLE_ADDRESS_BOOK" a on c.customers_id = a.customers_id and c.customers_default_address_id = a.address_book_id "$search" order by c.customers_lastname, c.customers_firstname";.

If you've got a keen eye you'll see that we've updated the query to select the "customers_usertype" field from the database when getting all of the other information so that no extra queries are needed. If you're wondering the "c." prefix to the field name is a prefix set later in the query to provide an extra definition to the table, so that ourselves and MySQL know what table we want to select from..

Now, to display this information on the right hand panel locate this code block in.

Admin/customers.php.

:.

If (isset($cInfo) && is_object($cInfo)) {.

$heading[] = array('text' => '<b>'$cInfo->customers_firstname' '$cInfo->customers_lastname'</b>');.

$contents[] = array('align' => 'center', 'text' => '<a href="'tep_href_link(FILENAME_CUSTOMERS, tep_get_all_get_params(array('cID', 'action'))'cID='$cInfo->customers_id'&action=edit')'">'tep_image_button('button_edit.gif', IMAGE_EDIT)'</a> <a href="'tep_href_link(FILENAME_CUSTOMERS, tep_get_all_get_params(array('cID', 'action'))'cID='$cInfo->customers_id'&action=confirm')'">'tep_image_button('button_delete.gif', IMAGE_DELETE)'</a> <a href="'tep_href_link(FILENAME_ORDERS, 'cID='$cInfo->customers_id)'">'tep_image_button('button_orders.gif', IMAGE_ORDERS)'</a> <a href="'tep_href_link(FILENAME_MAIL, 'selected_box=tools&customer='$cInfo->customers_email_address)'">'tep_image_button('button_email.gif', IMAGE_EMAIL)'</a>');.

$contents[] = array('text' => '<br>'TEXT_DATE_ACCOUNT_CREATED' 'tep_date_short($cInfo->date_account_created));.

$contents[] = array('text' => '<br>'TEXT_DATE_ACCOUNT_LAST_MODIFIED' 'tep_date_short($cInfo->date_account_last_modified));.

$contents[] = array('text' => '<br>'TEXT_INFO_DATE_LAST_LOGON' 'tep_date_short($cInfo->date_last_logon));.

$contents[] = array('text' => '<br>'TEXT_INFO_NUMBER_OF_LOGONS' '$cInfo->number_of_logons);.

$contents[] = array('text' => '<br>'TEXT_INFO_COUNTRY' '$cInfo->countries_name);.

$contents[] = array('text' => '<br>'TEXT_INFO_NUMBER_OF_REVIEWS' '$cInfo->number_of_reviews);.

}.

And replace it with:.

If (isset($cInfo) && is_object($cInfo)) {.

$heading[] = array('text' => '<b>'$cInfo->customers_firstname' '$cInfo->customers_lastname'</b>');.

$contents[] = array('align' => 'center', 'text' => '<a href="'tep_href_link(FILENAME_CUSTOMERS, tep_get_all_get_params(array('cID', 'action'))'cID='$cInfo->customers_id'&action=edit')'">'tep_image_button('button_edit.gif', IMAGE_EDIT)'</a> <a href="'tep_href_link(FILENAME_CUSTOMERS, tep_get_all_get_params(array('cID', 'action'))'cID='$cInfo->customers_id'&action=confirm')'">'tep_image_button('button_delete.gif', IMAGE_DELETE)'</a> <a href="'tep_href_link(FILENAME_ORDERS, 'cID='$cInfo->customers_id)'">'tep_image_button('button_orders.gif', IMAGE_ORDERS)'</a> <a href="'tep_href_link(FILENAME_MAIL, 'selected_box=tools&customer='$cInfo->customers_email_address)'">'tep_image_button('button_email.gif', IMAGE_EMAIL)'</a>');.

$contents[] = array('text' => '<br>Account type: '$cInfo->customers_usertype);.

$contents[] = array('text' => '<br>'TEXT_DATE_ACCOUNT_CREATED' 'tep_date_short($cInfo->date_account_created));.

$contents[] = array('text' => '<br>'TEXT_DATE_ACCOUNT_LAST_MODIFIED' 'tep_date_short($cInfo->date_account_last_modified));.

$contents[] = array('text' => '<br>'TEXT_INFO_DATE_LAST_LOGON' 'tep_date_short($cInfo->date_last_logon));.

$contents[] = array('text' => '<br>'TEXT_INFO_NUMBER_OF_LOGONS' '$cInfo->number_of_logons);.

$contents[] = array('text' => '<br>'TEXT_INFO_COUNTRY' '$cInfo->countries_name);.

$contents[] = array('text' => '<br>'TEXT_INFO_NUMBER_OF_REVIEWS' '$cInfo->number_of_reviews);.

}.

I haven't actually tested any of the code for the answers I've provided, but I'm confident, baring a typo, that it should all work as you desired...

Comment #5

Oh, and here's another tip...

When you perform an SQL query and execute the tep_db_fetch_array() function on it, the result returned is an array with the keys set as the field names from the database. For example...

$customer_query = tep_db_query("select customers_id, customers_firstname, customers_lastname from "TABLE_CUSTOMERS" where customers_id = '"$customer_id"'");.

$customer = tep_db_fetch_array($customer_query);.

The result is an array like this:.

Array('customers_id' => 1, 'customers_firstname' => Joe, 'customers_lastname' => Bloggs);.

To call the customers id you could use the variable $customer['customers_id'] because $customer is the variable where you performed the tep_db_fetch_array() and 'customers_id' is the name of the field in the database. To call the customers first name you would use $customer['customers_firstname']..

Hopefully I explained that well enough...

Comment #6

[quote name='Kanie' post='1349568' date='Dec 21 2008, 01:35 PM']Ok, one question at a time...

In.

Account.php.

Locate this code block:.

Echo $customer_usertype;.

Which returns "array" and.

Echo $customer_usertype['customer_usertype'];.

Which returns nothing. This makes me think that the if statement above used to echo info in comparing the result from the query (either "array" or "") to b, which of course will display nothing. I'm about to try the other code. I'll let you know how it works...

Comment #7

Good call abou this. I just took all the code to do with this out of the page, and set the default to "h" with myphpadmin. I don't know why I didn't think of this before, I've done this before, and it was easier than sorting through code...

Comment #8

[quote name='Kanie' post='1349576' date='Dec 21 2008, 02:05 PM']I assume you mean you want to display their account type on the right hand panel when selected? Easy enough...

In.

Admin/customers.php.

Locate this line:.

<?php.

$customers_type = tep_db_query("select customers_usertype from customers");.

$type = tep_db_fetch_array($customers_type);.

Echo $type;.

?>..

Comment #9

Are you 100% sure that the customer account you're logged in as has a "usertype" set in the database? The code I provided should definitely work..

If it does, then run this test by putting this code somewhere in.

Account.php.

..

$customer_info_query = tep_db_query("select * from "TABLE_CUSTOMERS" where customers_id = '"(int)$customer_id"'");.

$customer_info = tep_db_fetch_array($customer_info_query);.

Print_r($customer_info);.

This will print the returned array that contains all of the customers information from the database. You should see a key "customer_usertype" - what is it's value?..

Comment #10

Ok, I see you already have the extra column created. In order to call the "usertype" value from the array use $customers['customers_usertype']. So your HTML could would look like:.

<td class="dataTableContent"><?php echo $customers['customers_usertype']; ?></td>.

That should do the trick...

Comment #11

OK, it printed :.

Array ( [customers_id] => 2 [customers_gender] => [customers_usertype] => b [customers_firstname] => josh [customers_lastname] => dechant [customers_dob] => 1970-05-21 00:00:00 [customers_email_address] => [customers_default_address_id] => 2 [customers_telephone] => 7856509736 [customers_fax] => [customers_password] => ... [customers_newsletter] => 0 [reminder_sent] => 0 [customers_paypal_payerid] => [customers_paypal_ec] => 0 ).

AHHH I just figured out why it didn't work. On the original code, the "tep_db_query("select customer_usertype" was changed to "customers_usertype" which is the actual name of the table entry, so I just had to change the "if($customer_usertype['customer_usertype'] == "b") { " to "if($customer_usertype['customers_usertype'] == "b") {", and poof, it worked! Didn't catch that yesterday! Yay!..

Comment #12

Holy crap! That worked too! I could have sworn I tried that already. What a great day! Thank you for your help!..

Comment #13

No problem. I'm glad to see you got all your issues resolved...

Comment #14


This question was taken from a support group/message board and re-posted here so others can learn from it.

 

Categories: Home | Diet & Weight Management | Vitamins & Supplements | Herbs & Cleansing |

Sexual Health | Medifast Support | Nutrisystem Support | Medifast Questions |

Web Hosting | Web Hosts | Website Hosting | Hosting |

Web Hosting | GoDaddy | Digital Cameras | Best WebHosts |

Web Hosting FAQ | Web Hosts FAQ | Hosting FAQ | Hosting Group |

Hosting Questions | Camera Tips | Best Cameras To Buy | Best Cameras This Year |

Camera Q-A | Digital Cameras Q-A | Camera Forum | Nov 2010 - Cameras |

Oct 2010 - Cameras | Oct 2010 - DSLRs | Oct 2010 - Camera Tips | Sep 2010 - Cameras |

Sep 2010 - DSLRS | Sep 2010 - Camera Tips | Aug 2010 - Cameras | Aug 2010 - DSLR Tips |

Aug 2010 - Camera Tips | July 2010 - Cameras | July 2010 - Nikon Cameras | July 2010 - Canon Cameras |

July 2010 - Pentax Cameras | Medifast Recipes | Medifast Recipes Tips | Medifast Recipes Strategies |

Medifast Recipes Experiences | Medifast Recipes Group | Medifast Recipes Forum | Medifast Support Strategies |

Medifast Support Experiences |

 

(C) Copyright 2010 All rights reserved.