Textpattern CMS support forum
You are not logged in. Register | Login | Help
- Topics: Active | Unanswered
#331 2009-09-15 19:01:33
Re: mem_self_register
Yes, mem_self_register will let you use any field in the txp_user or ign_users table.
Ah but alas, the table I’m want to update/create stuff in is called smd_bio. This is good news for other sites I work on though.
Couple new questions for those in the know:
- Is a portion of the mem_self_register plugin code likely to point to a selectable third table in the future; or, is it easily modifiable or likely that you’ll (Manfre) make it so?
- Some of the fields in tables I want to update hold multiple comma separated values? Can these be managed from say, a form containing multi_select fields?
- Am I better off making use of mem_simple_form? If so see question number 2 again.
txtstrap (Textpattern + Twitter Bootstrap + etc…)
Offline
#332 2009-09-15 19:37:05
Re: mem_self_register
1. Table name is returned from the function mem_get_user_table_name, which you could easily modify. I didn’t know there was a 3rd user table option, so making this configurable might make sense.
2. This would require a new mem_form compatible function to provide a field for CSV values.
3. mem_simple_form will probably be easier for you to use, but it also relies upon mem_form so my #2 answer applies here.
Offline
#333 2009-09-15 19:49:59
Re: mem_self_register
Manfre wrote:
I didn’t know there was a 3rd user table option
Just fyi, smd_bio is not an entire user table, merely an extension of the existing one where the extra fields are associated with the txp_user table via the login name. It doesn’t alter the core table nor does it duplicate anything other than the login name; kind of a hybrid solution.
Whether having the mem_get_user_table_name configurable makes sense in the light of this new info nugget I don’t know.
Last edited by Bloke (2009-09-15 19:50:33)
The smd plugin menagerie — for when you need one more gribble of power from Textpattern. Bleeding-edge code available on GitHub.
Hire Txp Builders – finely-crafted code, design and Txp
Offline
#334 2009-09-15 19:51:56
Re: mem_self_register
Stef, thanks for the input.
Josh, you can’t use mem_self_register since it requires all the user information to be in the user table. You’ll have to use mem_simple_form.
Offline
#335 2009-09-15 20:11:22
Re: mem_self_register
Some of the fields in tables I want to update hold multiple comma separated values? Can these be managed from say, a form containing multi_select fields?
2. This would require a new mem_form compatible function to provide a field for CSV values.
I’ve been trying something similar recently. Until such a function exists (would be desirable), you can use a javascript (or jquery or similar) workaround and a trick. In your mem_form you make your own multiple select form element and directly after it a mem_form_hidden element with the name attribute name="string_your-db-field-name" (in the version below custom_2) and no content.
e.g. something like this in your mem_form form:
<label for="multiselect">Multiselect label</label>
<select id="multiselect" name="multiselect" multiple="multiple">
<option value="1">First option</option>
<option value="2">Second option</option>
<option value="3">Third option</option>
</select>
<txp:mem_form_hidden name="string_custom_2" value="" label="" />
You then use javascript/jquery to intercept the submit form event and transfer the choices made in the multiple select into the waiting empty mem_form_hidden element for processing as a normal string. You need to first convert the output array from the multiple select into a comma-separated list, then pass this value into the waiting empty mem_form_hidden element. With jquery it looks something like this:
<script type="text/javascript" src="http://mydomain.com/js/jquery-1.3.2.min.js"></script>
<script type="text/javascript">
$(document).ready(function()
{
$("form").submit(function() {
var options_list = [];
options_list = $.map($('#multiselect :selected'), function(e) { return $(e).val(); })
$("input[name=string_custom_2]").val(options_list);
});
});
</script>
Hope that helps.
TXP Builders – finely-crafted code, design and txp
Offline
#336 2009-09-15 21:09:57
Re: mem_self_register
Manfre wrote:
1. Table name is returned from the function mem_get_user_table_name, which you could easily modify. I didn’t know there was a 3rd user table option, so making this configurable might make sense.
Bloke wrote:
Whether having the mem_get_user_table_name configurable makes sense in the light of this new info nugget I don’t know.
I would say yes, but I don’t know if that’s something for everybody. I’m afraid I’m in over my head if I start hacking through mem_self_register.php, or for that matter; the whole mem suite. I wish I could offer a suggestion.
Manfre wrote:
2. This would require a new mem_form compatible function to provide a field for CSV values.
Jakob’s idea will help. I’m assuming a can use this method to Update a table field. The trick then when a user is editing their existing user detail(s) is to have the edit form draw from their existing details and for example: present a number of checkboxes, some of which are selected from a previous choice they made. They could then choose more boxes or uncheck some. Now when updating the field you would just write over the whole thing with a new comma separated list.
txtstrap (Textpattern + Twitter Bootstrap + etc…)
Offline
#337 2009-09-15 21:10:54
Re: mem_self_register
BTW, thanks Jakob for the idea. Maybe you have some ideas about my thoughts from my last post?
Last edited by whaleen (2009-09-15 21:12:03)
txtstrap (Textpattern + Twitter Bootstrap + etc…)
Offline
#338 2009-09-15 21:29:56
Re: mem_self_register
mem_form v0.6 supports multiselect and having the value stored as a delimited string, instead of being treated as an array of selected values.
Offline
#339 2009-09-15 21:48:32
Re: mem_self_register
Manfre wrote:
mem_form v0.6 supports multiselect and having the value stored as a delimited string, instead of being treated as an array of selected values.
Egad! Thanks Michael.
txtstrap (Textpattern + Twitter Bootstrap + etc…)
Offline
#340 2009-09-15 22:42:35
Re: mem_self_register
mem_form v0.6 supports multiselect and having the value stored as a delimited string, instead of being treated as an array of selected values.
Very nice, Michael. Thanks from me too! I made my own multiple-select function so I’d like to see how that works.
I’m assuming a can use this method to Update a table field. The trick then when a user is editing their existing user detail(s) is to have the edit form draw from their existing details…
Josh, the short answer is yes this works, but it is involved. I’ll write you a mail but I’m just back from 10 days of being away and have to deal with my overflowing inbox first. If you want to experiment yourself, I used smd_query and mem_simple_form in combination together with an url variable with the article id (smd_query can use this directly and validate that it is an integer). It works very well but there are a couple of problems along the way: firstly, dealing with data from the table that happens to contain special characters such as apostrophes etc. (they cause the txp-tag to exit prematurely). Both Stef/Bloke and Michael have added some attributes to escape/disable double-escaping special chars but I’m not sure if both new plugin versions are officially online yet. The second is dealing with textilised content if you’re using textpattern’s body and excerpt fields (you want to edit the Body field in textile notation but write both the Body and Body_html fields back to the database). For the latter I have used a similar jquery approach to the one outlined above. Michael has since also added a new option to mem_form/mem_simple_form to make this easier (again thanks Michael!) but I’ve not managed to make head or tail of his instructions, so I’ve not been able to try it yet.
and for example: present a number of checkboxes, some of which are selected from a previous choice they made. They could then choose more boxes or uncheck some…
I haven’t tried with Manfre’s mem_form_checkbox but I know from past experience with a non-txp project that updating checkboxes can be a bit tricky as only those boxes that have been checked are sent by the form. Checkboxes that have been switched off are not so you need to work out a way of sending ‘off’ states…
Last edited by jakob (2009-09-15 22:51:46)
TXP Builders – finely-crafted code, design and txp
Offline
#341 2009-09-16 07:47:28
Re: mem_self_register
Michael pulled mem_public_article out of his back pocket since my post. Maybe that does what you want? I’d love to hear how you get on with it if you do try it.
TXP Builders – finely-crafted code, design and txp
Offline
#342 2009-11-30 22:39:47
Re: mem_self_register
Sorry if I’ve come along late to this thread, but I’ve used the code suggested by renobird (#297) to create a self edit form for users.
The form itself displays nicely, with the form showing the current user’s details as the default. My problem is the submission of the form. When I try to submit, I get an error saying “You must provide a table name as an attribute to mem_simple_form on line 101”.
Now, if I look at renobird’s coding then mem_simple_form is not actually being called – is it being called in the background somehow? Otherwise, what do I need to add to this code to make the submit function work properly?
Nice plugin and I like the way it plays well with ign_password_protect too.
Offline
#343 2010-02-01 22:06:14
Re: mem_self_register
Finally got all of this working except for one issue.
I am developing a site on my laptop, using XAMPP with localhost email addresses.
However, the self edit form (<txp:mem_self_user_edit_form>) fails if I use a localhost email address (eg. “frank@localhost”). I know that it make sense to check for a valid email address for a live site, but is it possible to disable this checking for local development? This makes it hard to test the full functionality of changing addresses.
Also, I have enabled the plugin to accept a phone number, but the self edit form makes it mandatory ie. won’t accept the form without it. Is there some way of changing this so that it is not mandatory?
Thanks. Great plugin, works so well with ign_password_protect that I can’t believe it!
Offline
#344 2010-03-22 19:28:15
- FireFusion
- Member

- Registered: 2005-05-10
- Posts: 698
Re: mem_self_register
When register a new account this error message always appears above the form on the thankyou page. Even if the registration was successful and the new account is created.
Username already exists. Please try another name
My form looks like this…
<h2>Register</h2>
<txp:mem_self_register_form label="" login_url="http://www.gudrunpelham.com/textpattern/" thanks="You have successfully registered for an account. Your password has been mailed to you, please check your spam folder if it hasn't arrived.">
<div class="input">Real Name<br>
<txp:mem_form_text name="RealName" label="" break="" /></div>
<div class="input">Username<br>
<txp:mem_form_text name="name" label="" break="" /></div>
<div class="input">Email<br>
<txp:mem_form_email name="email" label="" break="" /></div>
<txp:mem_form_submit label="Register" button="1">Register</txp:mem_form_submit>
</txp:mem_self_register_form>
Last edited by FireFusion (2010-03-22 19:28:49)
Offline
#345 2010-04-15 21:53:25
Offline