This is the community forum. For a developer response use the Client Area.
Follow us on Facebook, Twitter and YouTube!

get the User name and email from db
#1

Hi guys

Actually I have question about if I can do a php code get the User name and user email from database table is called Customers, I mean I dont want the user to type name, email and country. I need the user to log in then if he/she wants to comment just they have to type something in the comment box, but the name, emails and country will be taking from that table.
I hope you can help.

Thank you
Reply
#2

Hi,

To set your own default form values:

1. Open comments/includes/commentics.php

2. Then above this (line 88):
PHP Code:
<?php 
cmtx_load_form_defaults
(); //load default values

Add these:
PHP Code:
<?php 
if (!isset($default_name)) { $default_name = $customer_name; }
if (!isset(
$default_email)) { $default_email = $customer_email; }
if (!isset(
$default_country)) { $default_country = $customer_country; }

Make sure that you set $customer_name, $customer_email and $customer_country with your own values from your Customers database table.

Have you completed the interview?
Reply
#3

Thank you very much Steven
it works ok but still I dont want the user to have a chance to change name or email, because now after those changes in the code the form has to include name input and email input to insert the user information to the db, but what I'm trying to do is to allow the user just to write a comment, I mean the form should display only the comment box, and the user information have to be inserted without changes.
Thank you again
Reply
#4

Okay, if you open comments/includes/template/form.php and find this bit (line 413):
PHP Code:
<?php
$elements
= explode(",", $settings->sort_order_fields);
foreach (
$elements as $element) {
switch (
$element) {
case
"1":
cmtx_output_name();
break;
case
"2":
cmtx_output_email();
break;
case
"3":
cmtx_output_website();
break;
case
"4":
cmtx_output_town();
break;
case
"5":
cmtx_output_country();
break;
case
"6":
cmtx_output_rating();
break;
}
}
?>

What you can do is add some CSS around the functions to not display them.

So if you didn't want to display the name field, it would be:
PHP Code:
<?php 
echo '<div style="display:none;">';
cmtx_output_name();
echo
'</div>';

Full example:
PHP Code:
<?php
$elements
= explode(",", $settings->sort_order_fields);
foreach (
$elements as $element) {
switch (
$element) {
case
"1":
echo
'<div style="display:none;">';
cmtx_output_name();
echo
'</div>';
break;
case
"2":
echo
'<div style="display:none;">';
cmtx_output_email();
echo
'</div>';
break;
case
"3":
cmtx_output_website();
break;
case
"4":
cmtx_output_town();
break;
case
"5":
echo
'<div style="display:none;">';
cmtx_output_country();
echo
'</div>';
break;
case
"6":
cmtx_output_rating();
break;
}
}
?>

Have you completed the interview?
Reply
#5

Thank you very much Steven

It works very well
Reply
#6

(22-Mar-2012, 04:25 PM)Abdul Wrote:  Thank you very much Steven

It works very well


Steven, I get this every time I try to comment using the change to default name:

You have just been banned.
This can be due to a variety of reasons including swearing, spamming and hacker-related behaviour.

If you feel that this was in error, please contact the administrator, quoting your IP Address.
Reply
#7

Hi jjevans, I answered this in your other thread:
http://www.commentics.org/forum/showthread.php?tid=499

Have you completed the interview?
Reply


Possibly Related Threads…
Thread / Author Replies Views Last Post
Last Post by Steven
28-Mar-2015, 01:45 PM
Last Post by skilife
13-May-2012, 01:11 PM

Forum Jump:


Users browsing this thread: 1 Guest(s)