How best to allow 'members' to update own publicly viewable profile (including an image).

  • I have an event site that currently uses the members app to allow companies to log-in and view private content. Additionally, I have a list of these same companies appearing at the event (including a logo, company name, biography) that is maintained by the site admin and uploaded as normal content.


    There is a need now for companies to be able to log-in and update their own profiles. Initially I thought the neatest solution would be to add the necessary fields to the existing member registration / profile forms on the front-end and add matching fields to the members.html to display in the admin. Using a third-party app (dh_member_profiles) I can loop through, and output, all of the members. However I quickly realised that this wasn't going to work as the front-end members form doesn't appear to support the processing of image / file uploads. I feel I may be wasting my time trying to get the members app to do this and I've come across a few fairly old forum posts about this that lead to a dead end (because the members app doesn't support image uploads). Is there a way, or workaround, to get this to work (as it otherwise appears to be a nice solution)?


    The only other approach I could think of was to create each of the companies as a user (approx 100 of them), only allow them to create or edit their own profile page and then pull all of these pages together into a single listing page using perch_content_custom(). This feels a bit clunky in comparison to the members route (not least because they already all have members logins and now will have admin logins also) but I can't think of another way of approaching it.


    Any suggestions or steer in the right direction would be much appreciated.

  • drewm

    Approved the thread.
  • Hello Gary,


    You can keep using Perch Members for user authentication, but you may have to manage the profiles outside of it. Even if you write a custom form handler to handle the file uploads, there's no public API for locating and updating Members.


    One option is to use a Runway Collection for the profiles and link each member to a Collection item. You'd need to write a custom form handler and use the collection import API to locate and update the Collection items. If you are dealing with images, you can also import them as Perch Assets or perhaps upload them straight to something like Cloudinary and only record the image URL in Perch.

  • Hi, thanks for the outline. In theory I grasp this but I'll need to go off and do a bit of further reading based on your suggestion. Currently I'm only using the basic Perch, not Runway, but Collections look interesting so probably the way to go. I may come back to this when I've made some progress.


    Thanks again

    Gary

  • Hi Hussein,


    So I've been thinking on this and looking at collections. Taking the first part of your suggestion – If I were to make the profiles a collection, collect all of the relevant data including the image, and link the relevant profile to each member, I understand with that how I could create their profile in the collection myself and link the profile to the member from the admin. What I don't grasp is how I would then provide them with a form on the site, like the member registration/profile form, that lets them populate / update their own profile in collections without them accessing the admin? Creating the form template for this is fine, but would this require a custom app to send the data to the collection? I'm struggling to find a relevant example of something like this. Apologies, I didn't really grasp the need for using the collection import API.


    Thanks,

    Gary

  • Creating the form template for this is fine, but would this require a custom app to send the data to the collection?


    Correct. In your form template you would add your app ID in the app attribute:


    HTML
    1. <perch:form app="gary_app_id"></perch:form>


    Your form handler function would go in your app's runtime file perch/addons/apps/gary_app_id/runtime.php:


    PHP
    1. function gary_app_id_form_handler($SubmittedForm) {
    2. if ($SubmittedForm->validate()) {
    3. }
    4. }



    Apologies, I didn't really grasp the need for using the collection import API.


    The Collections import API provides a way to interact with a Collection's items. Inside the form handler of your app you have access to data submitted by a user. This data is not saved in the database. It is your responsibility here to handle the data as you need. In this case you want to add the data to a Collection item. The import API is a documented and supported way to do that.

  • Thanks so much for coming back on that. It really helps as I've searched and failed to find anything explaining how to create a custom form handler and access the submitted data. Unless I'm missing it, that doesn't seem to be mentioned in the docs.


    Thanks again for your time, I'll install Runway and spend some time getting to grips with this.

  • Hello Gary,


    You can keep using Perch Members for user authentication, but you may have to manage the profiles outside of it. Even if you write a custom form handler to handle the file uploads, there's no public API for locating and updating Members.


    One option is to use a Runway Collection for the profiles and link each member to a Collection item. You'd need to write a custom form handler and use the collection import API to locate and update the Collection items. If you are dealing with images, you can also import them as Perch Assets or perhaps upload them straight to something like Cloudinary and only record the image URL in Perch.

    That's an interesting idea.