[FREE or $5 done today] Profile Field only Admin & Owner can see

Started by General Xbox Gaming, September 28, 2014, 11:07:40 AM

Previous topic - Next topic

General Xbox Gaming

I need a simple mod that looks for a value in smf_forummembers under column product_key and displays it on the owners Profile. It can only be edited by Admin but visible to Admin & Owner only.

Doesn't need to add the column product_key in the smf_forummembers, just simple look there (it's upto you!)

Location: preferable under e-mail address

I will be available to discuss this more after I finish work in 2hrs from now.

Kindred

You know that this is already possible with the standard smf custom profile fields?
Слaва
Украинi

Please do not PM, IM or Email me with support questions.  You will get better and faster responses in the support boards.  Thank you.

"Loki is not evil, although he is certainly not a force for good. Loki is... complicated."

General Xbox Gaming

Quote from: Kindred on September 28, 2014, 12:07:05 PM
You know that this is already possible with the standard smf custom profile fields?
I know but it doesn't put it in smf_formmembers. It ends up as a random variable in smf_forumthemes in a row instead of a column. I need it to look in smf_forummembers.

margarett

Yes, that's the place for custom profile fields.
To read it from there, easy peasy. But how do you plan to edit it? Because to mess with Profile-Modify it's a totally different story ;)
Se forem conduzir, não bebam. Se forem beber... CHAMEM-ME!!!! :D

QuoteOver 90% of all computer problems can be traced back to the interface between the keyboard and the chair

General Xbox Gaming

#4
Quote from: margarett on September 28, 2014, 03:03:16 PM
Yes, that's the place for custom profile fields.
To read it from there, easy peasy. But how do you plan to edit it? Because to mess with Profile-Modify it's a totally different story ;)
I would like to be able to edit it from Forum Profile Settings if that's possible but it's not necessary, although it would make modifying it easier, rather then opening PHP My Admin all the time.

I needs to read from smf_forummembers under "product_key"

This is how I am editing it at the moment:
<?
require "../Settings.php";
 
$user  $_REQUEST['user'];
 
        
mysql_connect($db_server$db_user$db_passwd);
        
mysql_select_db($db_name);
       
        
$result mysql_query("SELECT * FROM `".$db_prefix."members` WHERE `member_name` = '$user'");       
       
        if(
$result == false){
                die(
"User not found!");
        }

        
$row mysql_fetch_row($result);
        
        
$chars = array(0,1,2,3,4,5,6,7,8,9,"A","B","C","D","E","F","G","H","I","J","K","L","M","N","O","P","Q","R","S","T","U","V","W","X","Y","Z");
        
        
$serial '';
        
        
$max count($chars)-1;
                for(
$i=0;$i<5;$i++){
                        
$serial .= (!($i 5) && $i '-' '').$chars[rand(0$max)];
                }
      
        
$get_key "SMFPK-$serial-$serial-$serial"
	
/* Member ID */
	
   
	
$memid $row[0];
	
   
        
/* Username */
        
$username $row[1];
       
        
/* Group */
        
$group $row[4];

        
/* Get $Product_Key from Database*/     
        
$keyquery $row[61];
	
	
               
                if (
$keyquery == null AND $group==("1" OR "2" OR "3" OR "10"))
                        
$product_key $get_key;                        
                elseif (
$keyquery !== null AND $group==("1" OR "2" OR "3" OR "10"))
                        
$product_key $keyquery;
                else
                        
$product_key null;
	
	
	
	
	
	

        if (
$keyquery == null){
                
$sql="UPDATE ".$db_prefix."members SET product_key='$product_key' WHERE member_name = '$user'";
                
$result=mysql_query($sql);
        }
?>

Kindred

you are asking for a moderately complicated, custom mod, with no real additional use aside from your site, for $5?

I'd suggest that you, instead, modify your custom script to just read the standard location of the standard profile fields...
Слaва
Украинi

Please do not PM, IM or Email me with support questions.  You will get better and faster responses in the support boards.  Thank you.

"Loki is not evil, although he is certainly not a force for good. Loki is... complicated."

margarett

Which, if I might add, it's quite easy ;)
It's really just a query to the themes table, for user id and the field name that your custom field gets ;)

Also, you should be using SSI.php and $smcFunc for those queries ;)
Se forem conduzir, não bebam. Se forem beber... CHAMEM-ME!!!! :D

QuoteOver 90% of all computer problems can be traced back to the interface between the keyboard and the chair

Kindred

and if you need to write the variable from another script, it is the same thing... query to see if it exists in the themes table and update it if it does or add it if it doesn't....

that way, you can take advantage of internal SMF stuff without having to write custom scripts that will never be quite as good.
Слaва
Украинi

Please do not PM, IM or Email me with support questions.  You will get better and faster responses in the support boards.  Thank you.

"Loki is not evil, although he is certainly not a force for good. Loki is... complicated."

General Xbox Gaming

Quote from: margarett on September 28, 2014, 06:34:42 PM
Which, if I might add, it's quite easy ;)
It's really just a query to the themes table, for user id and the field name that your custom field gets ;)

Also, you should be using SSI.php and $smcFunc for those queries ;)

I literally learn as I go, so this sort of means nothing to me at the moment as I don't understand what you mean. I can re-code things but doing it without a reference is hard as I have no knowledge in php and MySQL.

margarett

I can prepare an example for you when I get to the computer ;)
Se forem conduzir, não bebam. Se forem beber... CHAMEM-ME!!!! :D

QuoteOver 90% of all computer problems can be traced back to the interface between the keyboard and the chair

General Xbox Gaming

Quote from: margarett on September 28, 2014, 07:04:17 PM
I can prepare an example for you when I get to the computer ;)
8) Thank you.

I really, only, just need something that can do what that code does via calling the code and then displays it in the users profile so they can see it.
I don't "need" to be able to edit it in the forum but it would be easier if I could.

Kindred

But that is what I was saying...   The custom profile fields already do all of that.

Слaва
Украинi

Please do not PM, IM or Email me with support questions.  You will get better and faster responses in the support boards.  Thank you.

"Loki is not evil, although he is certainly not a force for good. Loki is... complicated."

margarett

Actually, custom profile fields will not solve your problem out of the box, now that I was testing it...

There is no option in it to select a field that admin can edit and owner can see...

So, back to a custom MOD...
Se forem conduzir, não bebam. Se forem beber... CHAMEM-ME!!!! :D

QuoteOver 90% of all computer problems can be traced back to the interface between the keyboard and the chair

Kindred

Слaва
Украинi

Please do not PM, IM or Email me with support questions.  You will get better and faster responses in the support boards.  Thank you.

"Loki is not evil, although he is certainly not a force for good. Loki is... complicated."

General Xbox Gaming

Quote from: margarett on September 28, 2014, 08:08:02 PM
Actually, custom profile fields will not solve your problem out of the box, now that I was testing it...

There is no option in it to select a field that admin can edit and owner can see...

So, back to a custom MOD...
Thank you, I knew I wasn't talking dumb.
The custom_profile fields are stored in smf_forumthemes not smf_forummembers as I said in the first post.
All I really need is a new field in Profile that show the value of smf_formmembers under column: 'product_key'. If it's documented I can then go in a modify it later when I I've learn more about php.

Quote from: Kindred on September 28, 2014, 08:13:48 PM
I swear that there is such an option...
Your think of this I think: http://www.simplemachines.org/community/index.php?topic=511498.0

margarett

Don't swear. It's a sin to swear over a lie ;D ;D

The options are:
Users can see, owner can edit
Users can see, admins can edit
Users cannot see, owner and admins can edit
Only admins see

I also thought that there were such an option, but there isn't...

Quote from: General Xbox Gaming on September 28, 2014, 08:22:15 PM
Thank you, I knew I wasn't talking dumb.
The custom_profile fields are stored in smf_forumthemes not smf_forummembers as I said in the first post.
This is not a problem. They can easily be related by member ID ;)

Quote from: General Xbox Gaming on September 28, 2014, 08:22:15 PM
Quote from: Kindred on September 28, 2014, 08:13:48 PM
I swear that there is such an option...
Your think of this I think: http://www.simplemachines.org/community/index.php?topic=511498.0
Now THIS is a solution ;) With this, then Custom Profile fields do solve your problem ;)
Se forem conduzir, não bebam. Se forem beber... CHAMEM-ME!!!! :D

QuoteOver 90% of all computer problems can be traced back to the interface between the keyboard and the chair

Kindred

You still have not answered my questions as to WHY you feel that you must use a new column in the members table....      Why not use the functionality that is either already there, or at least 90% there instead of insisting on building a new thing from scratch?


Seriously... Why do you need to use this product_key field in the members table?   Why can you not use a field in the themes table?

Oh, and Bruno... Sins are for xtians...   :P
Слaва
Украинi

Please do not PM, IM or Email me with support questions.  You will get better and faster responses in the support boards.  Thank you.

"Loki is not evil, although he is certainly not a force for good. Loki is... complicated."

margarett

Because he probably doesn't see how to work in other way ;) That's our job, to show him the better option ;)
Se forem conduzir, não bebam. Se forem beber... CHAMEM-ME!!!! :D

QuoteOver 90% of all computer problems can be traced back to the interface between the keyboard and the chair

General Xbox Gaming

Quote from: Kindred on September 28, 2014, 08:31:18 PM
You still have not answered my questions as to WHY you feel that you must use a new column in the members table....      Why not use the functionality that is either already there, or at least 90% there instead of insisting on building a new thing from scratch?


Seriously... Why do you need to use this product_key field in the members table?   Why can you not use a field in the themes table?

Oh, and Bruno... Sins are for xtians...   :P
In smf_forummembers it's a column easier for me to modify/add/leave 'null' but if a custom_field is used it's a row only there when a user has inputed a value, else it doesn't exist. I need to use it in C# via a MySQL query to authenticate the software. I haven't released it yet as it's in Alpha right now and I just want to get this out of the way first.

Kindred

Right... So, you check if it exists... If not, then the value is null. If so, then the value is populated.

Again, much simpler than creating a whole new field and interface for that field.
Слaва
Украинi

Please do not PM, IM or Email me with support questions.  You will get better and faster responses in the support boards.  Thank you.

"Loki is not evil, although he is certainly not a force for good. Loki is... complicated."

Advertisement: