ExpressionEngine CMS
Open, Free, Amazing

Thread

This is an archived forum and the content is probably no longer relevant, but is provided here for posterity.

The active forums are here.

Using url_title= "{variable}" with Safecracker

April 06, 2012 11:46am

Subscribe [1]
  • #1 / Apr 06, 2012 11:46am

    tylonius

    4 posts

    This question may be related to a resolved thread.

    The above issue was marked as resolved, but I didn’t see the solution.

    I’m using channels to store member profile data, and Safecracker to edit those entries.

    To connect the user to the appropriate entry, I’m setting the url_title to be “member{member_id}” and trying to use that with the Safecracker form.

    What I can’t seem to get Safecracker to do is process the variable.

    So, if I do this:

    {exp:safecracker channel="members" return="contact/thanks" url_title="member{logged_in_member_id}"}

    I get a blank form.

    If I manually enter the member id:

    {exp:safecracker channel="members" return="contact/thanks" url_title="member23"}

    I get the edit form I’m looking for.

    Are there only certain variables that Safecracker will process?

  • #2 / Apr 09, 2012 11:05am

    Dan Decker

    7338 posts

    Hi tylonius,

    I think I have a solution that should get you what you are after.

    If you are linking to these profiles from another template, you can pass the value to your SafeCracker via the URL and use the segment variable.

    Create your edit profile link like so:

    <a href="http://{path=profile/edit/}member{logged_in_member_id}">Edit your Profile</a>

    Then on your SafeCracker template, use the parameter like so:

    {exp:safecracker channel="members" return="contact/thanks" url_title="{segment_3}"}

    For added security, you can use the author_only parameter to ensure that only the member or a Super Admin is allowed to edit their profile:

    {exp:safecracker channel="members" return="contact/thanks" url_title="{segment_3}" author_only="yes"}

    Let me know if you have any questions!

    Cheers,

  • #3 / Apr 11, 2012 9:41am

    tylonius

    4 posts

    That was the solution to the referring thread, but it leaves me with the same question: Are there only certain variables or variable types that SC will process there?

    The {segment_3} approach is what I’m doing now, and with the author_only function turned on. However, I’d really rather not have the member id be in the URL in the first place.

  • #4 / Apr 11, 2012 3:56pm

    Dan Decker

    7338 posts

    Hi tylonius,

    However, I’d really rather not have the member id be in the URL in the first place.

    Awesome! The author_only= parameter is all you need then. It checks against the logged in user. If the logged in user is the author, then they are allowed to edit the entry. No need to worry about passing the member_id at any point along the way!

    Cheers,

.(JavaScript must be enabled to view this email address)

ExpressionEngine News!

#eecms, #events, #releases