Thread subject: Official Home of the PHPFusion CMS :: Cant get userfield to work.. or enable

Posted by diesltek710 on 17-10-2022 04:50
#1

sample code based from irq / aim as those are similar fields i need to add to the registration... when i try to enable nothing happens and when i manually add the tables to my data base i get this error

Quote

Error: Check the files of the user field user_av_6!


Code
<?php
/*-------------------------------------------------------+
| PHPFusion Content Management System
| Copyright (C) PHP Fusion Inc
| https://phpfusion.com/
+--------------------------------------------------------+
| Filename: user_av_6_include.php
| Author: Digitanium
+--------------------------------------------------------+
| This program is released as free software under the
| Affero GPL license. You can redistribute it and/or
| modify it under the terms of this license which you
| can read by viewing the included agpl.txt or >isError()) {
 $user_av_6 = isset($_POST['user_av_6']wink ? stripinput($_POST['user_av_6']wink : $user_av_6;
 }

 echo "<tr>n";
 echo "<td class='tbl".$this->getErrorClass("user_av_6"wink."'><label for='user_av_6'>".$locale['uf_icq'].$required."</label></td>n";
 echo "<td class='tbl".$this->getErrorClass("user_av_6"wink."'>";
 echo "<input type='text' id='user_av_6' name='user_av_6' value='".$user_av_6."' maxlength='16' class='textbox' style='width:200px;' />";
 echo "</td>n</tr>n";

 if ($required) {
 $this->setRequiredJavaScript("user_av_6", $locale['uf_icq_error']wink;
 }

 // Display in profile
} else if ($profile_method == "display"wink {
 if ($user_data['user_av_6']wink {
 echo "<tr>n";
 echo "<td class='tbl1'>".$locale['uf_icq']."</td>n";
 echo "<td align='right' class='tbl1'>".$user_data['user_av_6']."</td>n";
 echo "</tr>n";
 }

 // Insert and update
} else if ($profile_method == "validate_insert" || $profile_method == "validate_update"wink {
 // Get input data
 if (isset($_POST['user_av_6']wink && ($_POST['user_av_6'] != "" || $this->_isNotRequired("user_av_6"wink)) {
 if (isnum($_POST['user_av_6']wink || $_POST['user_av_6'] == ""wink {
 // Set update or insert user data
 $this->_setDBValue("user_av_6", $_POST['user_av_6']wink;
 } else {
 $this->_setError("user_av_6", $locale['uf_icq_error2']wink;
 }
 } else {
 $this->_setError("user_av_6", $locale['uf_icq_error'], TRUE);
 }
}


Code
<?php
/*-------------------------------------------------------+
| PHPFusion Content Management System
| Copyright (C) PHP Fusion Inc
| https://phpfusion.com/
+--------------------------------------------------------+
| Filename: user_icq_include_var.php
| Author: Digitanium
+--------------------------------------------------------+
| This program is released as free software under the
| Affero GPL license. You can redistribute it and/or
| modify it under the terms of this license which you
| can read by viewing the included agpl.txt or >
| at www.gnu.org/licenses/agpl.html. Removal of this
| copyright header is strictly prohibited without
| written permission from the original author(s).
+--------------------------------------------------------*/
if (!defined("IN_FUSION"wink) {
 die("Access Denied"wink;
}

// Version of the user fields api
$user_field_api_version = "1.01.00";

$user_field_name = '+6 Avail.';
$user_field_desc = 'Are you availible at +6?';
$user_field_dbname = "user_av_6";
$user_field_group = 1;
$user_field_dbinfo = "VARCHAR(3) NOT NULL DEFAULT ''";

Posted by diesltek710 on 17-10-2022 05:33
#2

I have added the colums into my database but cant even hard code the items in to register...

i am trying to make a form like the one below to update the tables i made in my user database already.
but im stuck what to do to make it update / add to my db table....

Code
<div class="">
 <div class="">
 <h1 access="false" id="control-7207556">Stats for Eden</h1></div>
 <div class="">
 <label for="select-footmen" class="">Footmen<span class="">*</span><span class="tooltip-element" tooltip="highest footmen level you have">?</span></label>
 <select class="form-control" name="select-footmen" id="select-footmen" required="required" aria-required="true">
 <option disabled="null" selected="null">-</option>
 <option value="T7" id="select-footmen-0">T7</option>
 <option value="T8" id="select-footmen-1">T8</option>
 <option value="T9" id="select-footmen-2">T9</option>
 <option value="T10" id="select-footmen-3">T10</option>
 </select>
 </div>
 <div class="">
 <label for="select-archers" class="">Archers<span class="formbuilder-required">*</span><span class="tooltip-element" tooltip="highest archers level you have">?</span></label>
 <select class="form-control" name="select-archers" id="select-archers" required="required" aria-required="true">
 <option disabled="null" selected="null">-</option>
 <option value="T7" id="select-archers-0">T7</option>
 <option value="T8" id="select-archers-1">T8</option>
 <option value="T9" id="select-archers-2">T9</option>
 <option value="T10" id="select-archers-3">T10</option>
 </select>
 </div>
 <div class="">
 <label for="select-cavs" class="">Calvery<span class="">*</span><span class="tooltip-element" tooltip="highest calvery level you have">?</span></label>
 <select class="form-control" name="select-cavs" id="select-cavs" required="required" aria-required="true">
 <option disabled="null" selected="null">-</option>
 <option value="T7" id="select-cavs-0">T7</option>
 <option value="T8" id="select-cavs-1">T8</option>
 <option value="T9" id="select-cavs-2">T9</option>
 <option value="T10" id="select-cavs-3">T10</option>
 </select>
 </div>
 <div class="">
 <label for="number-loyalty" class="">Loyalty Level<span class="">*</span><span class="tooltip-element" tooltip="eden loyalty level">?</span></label>
 <input type="number" placeholder="0" class="form-control" name="number-loyalty" access="false" value="2000" id="number-loyalty" title="eden loyalty level" required="required" aria-required="true">
 </div>
 <div class="">
 <label for="radio-time" class="">Available Times<span class="tooltip-element" tooltip="times best for you to participate in eden">?</span></label>
 <div id='MultiSelect_container' class='sfm_multiselect element_label'>
 <ul id='MultiSelect_ul'>
 <li ><label ><input type='checkbox' name='MultiSelect[]' value='Reset'>Reset</label></li>
 <li ><label ><input type='checkbox' name='MultiSelect[]' value='+6'>+6</label></li>
 <li ><label ><input type='checkbox' name='MultiSelect[]' value='+8'>+8</label></li>
 <li ><label ><input type='checkbox' name='MultiSelect[]' value='+12'>+12</label></li>
 <li ><label ><input type='checkbox' name='MultiSelect[]' value='+16'>+16</label></li>
 <li ><label ><input type='checkbox' name='MultiSelect[]' value='+18'>+18</label></li>
 <li ><label ><input type='checkbox' name='MultiSelect[]' value='+23'>+23</label></li>
 </ul>
 </div>
 </div>
 </div>
    <div id='Submit_container' class='loading_div sfm_element_container'>
 <input type='image' name='Submit' id='Submit' alt='submit'>
 </div>
</div>


i have also included a screenshot of what my database looks like and what the output looks like. but i cant get it to work with user fileds in registration, or making a separate page to enter these fields... pleased help im on a tight deadline...

Edited by diesltek710 on 17-10-2022 20:31

Posted by diesltek710 on 17-10-2022 17:55
#3

So i have managed to get the user fields to enable themselves but after i enable them i am still getting

Quote

Error: Check the files of the user field user_av_reset!


Code
if (!defined("IN_FUSION"wink) {
 die("Access Denied"wink;
}

// Display user field input
if ($profile_method == "input"wink {
 $user_av_reset = isset($user_data['user_av_reset']wink ? stripinput($user_data['user_av_reset']wink : "";
 if ($this->isError()) {
 $user_av_reset = isset($_POST['user_av_reset']wink ? stripinput($_POST['user_av_reset']wink : $user_av_reset;
 }

 echo "<tr>n";
 echo "<td class='tbl".$this->getErrorClass("user_av_reset"wink."'><label for='user_av_reset'>".$locale['uf_location'].$required."</label></td>n";
 echo "<td class='tbl".$this->getErrorClass("user_av_reset"wink."'>";
 echo "<input type='text' id='user_av_reset' name='user_av_reset' value='".$user_av_reset."' maxlength='50' class='textbox' style='width:200px;' />";
 echo "</td>n</tr>n";

 if ($required) {
 $this->setRequiredJavaScript("user_av_reset", $locale['uf_location_error']wink;
 }

 // Display in profile
} else if ($profile_method == "display"wink {
 if ($user_data['user_av_reset']wink {
 echo "<tr>n";
 echo "<td class='tbl1'>".$locale['uf_location']."</td>n";
 echo "<td align='right' class='tbl1'>".$user_data['user_av_reset']."</td>n";
 echo "</tr>n";
 }

 // Insert and update
} else if ($profile_method == "validate_insert" || $profile_method == "validate_update"wink {
 // Get input data
 if (isset($_POST['user_av_reset']wink && ($_POST['user_av_reset'] != "" || $this->_isNotRequired("user_av_reset"wink)) {
 // Set update or insert user data
 $this->_setDBValue("user_av_reset", stripinput(trim($_POST['user_av_reset']wink));
 } else {
 $this->_setError("user_av_reset", $locale['uf_location_error'], TRUE);
 }
}

Edited by diesltek710 on 17-10-2022 18:13

Posted by douwe_yntema on 17-10-2022 20:04
#4

Did you make locale files for the new userfield?

Posted by diesltek710 on 17-10-2022 20:28
#5

no i have not. im not going to have them localized i will manually type them out in english. I just left it as is for now because im just trying to get it to work first.

Posted by douwe_yntema on 17-10-2022 20:47
#6

That is your problem, you need a locale file for the description of the user field. See existing ones for an example

Posted by diesltek710 on 17-10-2022 21:03
#7

thanks but i just tried to update it and i still have that error...

Posted by karrak on 18-10-2022 12:17
#8

the name of the database is user_av_6, but according to your program it asks for the name user_av_reset
but that won't be good either. do not include _ in the name. for example user_avreset_include.php
although I don't understand the above code, where does it go

Edited by karrak on 18-10-2022 12:18

Posted by diesltek710 on 18-10-2022 17:13
#9

Thank you i will try that

Posted by diesltek710 on 18-10-2022 18:26
#10

I tried to remove the extra _ and i am stil having this issue! the tables are made in the user table but gives me an error still as seen in the screenshot. locale files are named correctly, everything is correct... still cant make it work

user_6_include_var.php
Code
<?php

if (!defined("IN_FUSION"wink) {
 die("Access Denied"wink;
}

// Version of the user fields api
$user_field_api_version = "1.01.00";

$user_field_name = '+6 Avail.';
$user_field_desc = 'Are you availible at +6?';
$user_field_dbname = "user_62";
$user_field_group = 1;
$user_field_dbinfo = "VARCHAR(3) NOT NULL DEFAULT ''";


user_6_include.php

Code
<?php

if (!defined("IN_FUSION"wink) {
 die("Access Denied"wink;
}

// Display user field input
if ($profile_method == "input"wink {
 $user_62 = isset($user_data['user_62']wink ? $user_data['user_62'] : "";
 if ($this->isError()) {
 $user_62 = isset($_POST['user_62']wink ? stripinput($_POST['user_62']wink : $user_62;
 }

 echo "<tr>n";
 echo "<td class='tbl".$this->getErrorClass("user_62"wink."'><label for='user_62'>".$locale['uf_6'].$required."</label></td>n";
 echo "<td class='tbl".$this->getErrorClass("user_62"wink."'>";
 echo "<input type='text' id='user_62' name='user_62' value='".$user_62."' maxlength='3' class='textbox' style='width:200px;' />";
 echo "</td>n</tr>n";

 if ($required) {
 $this->setRequiredJavaScript("user_62", $locale['uf_6_error']wink;
 }

 // Display in profile
} else if ($profile_method == "display"wink {
 if ($user_data['user_62']wink {
 echo "<tr>n";
 echo "<td class='tbl1'>".$locale['uf_6']."</td>n";
 echo "<td align='right' class='tbl1'>".$user_data['user_62']."</td>n";
 echo "</tr>n";
 }

 // Insert and update
} else if ($profile_method == "validate_insert" || $profile_method == "validate_update"wink {
 // Get input data
 if (isset($_POST['user_62']wink && ($_POST['user_62'] != "" || $this->_isNotRequired("user_62"wink)) {
 if (isnum($_POST['user_62']wink || $_POST['user_62'] == ""wink {
 // Set update or insert user data
 $this->_setDBValue("user_62", $_POST['user_62']wink;
 } else {
 $this->_setError("user_62", $locale['uf_6_error2']wink;
 }
 } else {
 $this->_setError("user_62", $locale['uf_6_error'], TRUE);
 }
}


locale user_6.php

Code
<?php
$locale['uf_6] = "+6";
$locale['uf_6_desc'] = "+6 Avail";
$locale['uf_6_error'] = "Can not be left empty.";
$locale['uf_6_error2'] = "test.";
?>

Posted by karrak on 18-10-2022 19:20
#11

good in principle

Posted by diesltek710 on 19-10-2022 19:51
#12

Thank you!!

that seemed to work. any idea how i can do this with check boxes? like in my form code above?

or is there a way to have a userfields category display on a different page? like update_stats.php ?

Posted by karrak on 20-10-2022 06:34
#13

[quote name=diesltek710 post=211816]@diesltek710 -
or is there a way to have a userfields category display on a different page? like update_stats.php ?[/quote]

there is none.

Edited by karrak on 20-10-2022 06:35

Posted by douwe_yntema on 20-10-2022 07:30
#14

I am not sure but I think then you must modify the core

You can try place them in a separate category