2

After a member is registered via Safecracker Registration, how do I allow the member to update his/her Channel entry?

Safecracker Registration has the option edit_member="yes", so I created a Safecracker form with the fields I want members to be able to update. The opening tag is something like this:

{exp:safecracker channel="members" class="form-horizontal" edit_member="yes" error_handling="inline" id="profile_manager_about_me" include_jquery="no" return="/profile-manager/" safecracker_head="no"}

While the member is logged in and submits the Safecracker form, a field error is returned stating that the email field is required (it's not one of the fields to be edited).

Is Safecracker Registration's edit_member="yes" only supposed to be used when you are also editing member data along with possibly the Channel entry data? How can I edit just the Channel entry data?

Could I use the global variable member_id to get the current member's entry in the Channel, then get that result's entry_id (there should only be one, I think), then use the entry_id as a parameter in the Safecracker tag pair? Seems convoluted?

  • You mention channel entry: are you using an add-on like Zoo Visitor or Profile:Edit as well? – Tyssen Jan 7 '13 at 11:26
  • Yes. It's called "Safecracker Registration." – ExpressionEngineNewbie Jan 7 '13 at 11:34
  • Do you mean to complete their profile? Are they not doing so during the registration process— submitting the other fields of data? – nonprofit_tech Jan 7 '13 at 12:28
  • No. The registration only accepts the email address + password + confirm password + a couple of Channel fields. There are more fields than what I expose during the registration process. – ExpressionEngineNewbie Jan 7 '13 at 13:06
  • @Tyssen It's my add-on Safecracker Registration. It's the same concept as those add-ons, but a little more basic. I use it on all my client sites and is all I ever need with how I build sites. – Justin Kimbrell Jan 8 '13 at 5:46
2

You need to use the edit_member="yes" parameter in conjunction with using the member fields from your registration form. If you don't want those fields, just make this a standard safecracker form and edit your profile entry as normal.

There are several ways you can do it, but my advise would to use hidden form fields to store the values you don't want to be visible. This way, you don't have to workaround any unforeseen limitations you may come across.

| improve this answer | |
  • So, say there is a hidden field "email" with the current member's email address, then it's OK? What about using the current member's member_id to get the related Channel entry, then just using a standard Safecracker form for that? I'm just reluctant about the hidden field approach. – ExpressionEngineNewbie Jan 8 '13 at 9:23
  • Wait - what do you mean by "member fields?" I've decided to only use the bare minimum EE member fields (email, password, password_confirm). Everything else was put in a Channel field. I want to edit the data stored in the Channel associated with the member. – ExpressionEngineNewbie Jan 8 '13 at 9:50
  • Right, the member fields include the email, password, and password_confirm fields. You can use the screen_name and username fields as well, but those are optional and default to the email if that don't exists. I typically include the email and password fields when users are updating their profile. However, if you want to prevent users from updating them, just include them as hidden fields. – Justin Kimbrell Jan 8 '13 at 13:48
  • I haven't had the time to explore these options. Will do soon. Quick question about the hidden field approach: if I were to manipulate the DOM and replace the email address with another member's, would I be modifying his/her Channel entry when I submit the form? – ExpressionEngineNewbie Jan 10 '13 at 13:59
  • TBH I am not sure what would happen, that's probably a good thing to test. I don't usually have to go that degree of security and just use hidden fields because the problem has never come up. Normally I just leave the field visible and it can be changed at will, so I don't see how making it hidden would be any less secure. – Justin Kimbrell Jan 10 '13 at 14:27
1

In fact I think that the e-mail address field is required, but you can hide it in a hidden field.

| improve this answer | |
  • Perhaps. It makes sense to be required on registration. Maybe not so much when editing? Hidden field seems prone to possible hacking. Would probably be better to figure out the entry_id by using the member_id somehow? Just seems convoluted. – ExpressionEngineNewbie Jan 7 '13 at 19:27
  • You don't have to use it or make it a hidden field, but this would make your form a regular Safecracker tag and nothing to do with the registration components. When you use edit_member you are editing a profile, to which the email and password fields belong. I use hidden fields all the time, and sometimes are the easiest way to solve the problem. Nothing wrong with it on a technical level IMO. – Justin Kimbrell Jan 8 '13 at 13:50

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.