Skip Navigation

[Resolved] Allow members to edit their member profile

This thread is resolved. Here is a description of the problem and solution.

Problem:

The issue here is that the user wanted to have their customer's edit their own content on the frontend.

Solution:

This can be done by creating a frontend edit form and following the instructions in the link below.
https://toolset.com/documentation/getting-started-with-toolset/publish-content-from-the-front-end/forms-for-editing/

This support ticket is created 5 years, 10 months ago. There's a good chance that you are reading advice that it now obsolete.

This is the technical support forum for Toolset - a suite of plugins for developing WordPress sites without writing PHP.

Everyone can read this forum, but only Toolset clients can post in it. Toolset support works 6 days per week, 19 hours per day.

No supporters are available to work today on Toolset forum. Feel free to create tickets and we will handle it as soon as we are online. Thank you for your understanding.

Sun Mon Tue Wed Thu Fri Sat
- 9:00 – 12:00 9:00 – 12:00 9:00 – 12:00 9:00 – 12:00 9:00 – 12:00 -
- 13:00 – 18:00 13:00 – 18:00 13:00 – 18:00 14:00 – 18:00 13:00 – 18:00 -

Supporter timezone: America/Jamaica (GMT-05:00)

This topic contains 62 replies, has 2 voices.

Last updated by laurieB 5 years, 10 months ago.

Assisted by: Shane.

Author
Posts
#1180990

I'm sorry, kinda freaking out as this was supposed to be handed off yesterday.

1) I have changed to post_title, will you add the code, or provide?
2) Christian helped me with these. The dropdown needed to be conditional, so you select the category and the appropriate sub categories showed up in another dropdown. How do I get them to show up in the custom post? They all show up on the member profile page when selected. I have no idea???
3) This archive: hidden link search for Jim Fadden or Jim the Wine Guy.

#1180991

Shane,
Thank you!! I greatly appreciate your help with this. It's so close.

#1181011

Shane
Supporter

Languages: English (English )

Timezone: America/Jamaica (GMT-05:00)

Hi Laurie,

Here is the code that is needed.

add_action('cred_save_data', 'set_company_name',10,2);
function set_company_name($post_id, $form_data)
{
    // if a specific form
    if ($form_data['id']==12)
    {
       $title = get_the_title($post_id);
update_post_meta($post_id, 'wpcf-company_name',$title);
    }
}

Please try this and let me know if it helps. Please change the 12 to the id of you form.

Thanks,
Shane

#1181035

I added the code, tested and activated. This did not resolve the post name. Also did not create a profile page.

#1181543

Shane
Supporter

Languages: English (English )

Timezone: America/Jamaica (GMT-05:00)

Hi Laurie,

I see what you mean. I also see the problem.

There is a redundancy here. You name the Company Name custom field as Post Title, which caused it to have the slug post_title. Now this is the same slug that the default post title field has.

What I did was to change the slug of the Company Name field and it is now working.

I've tested it even with the code I gave and its working perfectly now.
Thanks,
Shane

#1181570

Hi Shane,

Perfect! Thank you. Thant makes sense.

The last concern is #2. When a new member fills out the form I need to capture the category and sub-category. Christian Cox helped me with that support ticket to set up all the conditional dropdowns. There is custom code in place. This is the link to the support thread from before. I need to capture these on the back end, as they show up on the profile pages. The categories/sub from the new member we added did not show up.

https://toolset.com/forums/topic/adding-a-new-sub-category-to-the-list/

Thank you,
Laurie

#1181669

Shane
Supporter

Languages: English (English )

Timezone: America/Jamaica (GMT-05:00)

Hi Laurie,

Is the issue with selecting the category ? or is it with displaying the category on their profiles.

Example here
hidden link

Please let me know.

Thanks,
Shane

#1181761

Hi Shane,

Members are able to select a category, and sub-category when filing out the form, however the results do not show up in the custom post that is pending approval on the back end. The checkboxes under business categories are not checked, and the approver would have no idea of what was selected, therefore they will NOT show up on the profile page.

An existing member can edit their profile, yet their original selection does not show up as selected. The business categories are used for searching and sorting as well.

Thank you for your help!
Laurie

#1182319

Shane
Supporter

Languages: English (English )

Timezone: America/Jamaica (GMT-05:00)

Screenshot 2019-01-11 at 9.27.13 AM.png

Hi Laurie,

I've looked at this again for you.

I was able to get the taxonomy to be set with a modification of this code here.

add_action('cred_save_data', 'set_company_name',10,2);
function set_company_name($post_id, $form_data)
{
    // if a specific form
    if ($form_data['id']=4305)
    {
       $title = get_the_title($post_id);
		update_post_meta($post_id, 'wpcf-company_title',$title);
     	if (isset($_POST['gen-biz-category'])){
         	wp_set_post_terms($post_id,$_POST['gen-biz-category'],'business-category');
          	if(isset($_POST['animal-care'])){
                wp_set_post_terms($post_id,$_POST['animal-care'],'business-category',true);
          	}
        }
    }
}

As you can see this is the original code that I gave you with some modifications.

The actual modification is this.

if (isset($_POST['gen-biz-category'])){
         	wp_set_post_terms($post_id,$_POST['gen-biz-category'],'business-category');
          	if(isset($_POST['animal-care'])){
                wp_set_post_terms($post_id,$_POST['animal-care'],'business-category',true);
          	}
        }

Where i'm checking if the customer selects the taxonomy and if they did, i update the post with the correct terms.

Now what you need to do is to add the condition for each child section. As you can see i've added the code to check if the user select Animal Care and then set the child selection for animal care.

To add a the checks for the other terms you will need to add an if statement. Here is an example if the user selected Arts Literature.

if (isset($_POST['gen-biz-category'])){
         	wp_set_post_terms($post_id,$_POST['gen-biz-category'],'business-category');
          	if(isset($_POST['animal-care'])){
                wp_set_post_terms($post_id,$_POST['animal-care'],'business-category',true);
          	}

if(isset($_POST['arts-literature'])){
                wp_set_post_terms($post_id,$_POST['arts-literature'],'business-category',true);
          	}
        }

Notice all I did was to just add a new if statement within the gen-biz-category if statement as this is a nested code.

Now finally the most important thing is that when we are using the wp_set_post_terms() function we are required to use the term ID rather than the slug. What you have on the form is the term slug as your value. See Screenshot

If you Notice for the Animal Care option I replaced the slug with the Term ID. The term ID can be found by editing the taxonomy term and look for the tag_ID parameter in the URL.

This is going to take some changes but should work perfectly fine after you've added the necessary code and made changes to your value attribute.

Please let me know if this helps.
Thanks,
Shane

#1182399

Thank you Shane! I really appreciate your help with this!

This is a very clear explanation of what needs to be done. I understand the steps and will implement now. I'll reach out with questions.

#1182402

One question. Will this also capture the sub-category, or do I need to do this for every sub-category listing as well? Fingers crossed that's a no.

#1182414
Screen Shot 2019-01-11 at 1.00.05 PM.png
Screen Shot 2019-01-11 at 12.50.21 PM.png

Hi Shane,

I have added this code and I'm getting a syntax and another error. See screenshot.

<?php
toolset_snippet_security_check() or die( 'Direct access is not allowed' );

/**
 * New custom code snippet.
 * Company Name
 * Post ID for Business categories
 */
add_action('cred_save_data', 'set_company_name',10,2);
function set_company_name($post_id, $form_data)
{
    // if a specific form
    if ($form_data['id']=4305)
    {
       $title = get_the_title($post_id);
		update_post_meta($post_id, 'wpcf-company_title',$title);
               wp_set_post_terms($post_id,$_POST['gen-biz-category'],'business-category');
     	if (isset($_POST['gen-biz-category'])){
         wp_set_post_terms($post_id,$_POST['gen-biz-category'],'business-category');
      if(isset($_POST['animal-care'])){
          wp_set_post_terms($post_id,$_POST['animal-care'],'business-category',true);
      if(isset($_POST['arts-literature'])){
          wp_set_post_terms($post_id,$_POST['arts-literature'],'business-category',true);
      if(isset($_POST['beauty-spa'])){
          wp_set_post_terms($post_id,$_POST['beauty-spa'],'business-category',true);
      if(isset($_POST['care-coordinator'])){
          wp_set_post_terms($post_id,$_POST['care-coordinator'],'business-category',true);
      if(isset($_POST['childrens-needs'])){
          wp_set_post_terms($post_id,$_POST['childrens-needs'],'business-category',true);
      if(isset($_POST['diversity-multi-cultural'])){
          wp_set_post_terms($post_id,$_POST['diversity-multi-cultural'],'business-category',true);
      if(isset($_POST['education'])){
          wp_set_post_terms($post_id,$_POST['education'],'business-category',true);
      if(isset($_POST['fashion'])){
          wp_set_post_terms($post_id,$_POST['fashion'],'business-category',true);
      if(isset($_POST['food-drink'])){
          wp_set_post_terms($post_id,$_POST['food-drink'],'business-category',true);
      if(isset($_POST['goods-retail'])){
          wp_set_post_terms($post_id,$_POST['goods-retail'],'business-category',true);
      if(isset($_POST['health-wellness'])){
          wp_set_post_terms($post_id,$_POST['health-wellness'],'business-category',true);
      if(isset($_POST['home-garden'])){
          wp_set_post_terms($post_id,$_POST['home-garden'],'business-category',true);
      if(isset($_POST['legal-financial'])){
          wp_set_post_terms($post_id,$_POST['legal-financial'],'business-category',true);
      if(isset($_POST['non-profit'])){
          wp_set_post_terms($post_id,$_POST['non-profit'],'business-category',true);
      if(isset($_POST['professional-services'])){
          wp_set_post_terms($post_id,$_POST['professional-services'],'business-category',true);
      if(isset($_POST['real-estate'])){
          wp_set_post_terms($post_id,$_POST['real-estate'],'business-category',true);
      if(isset($_POST['technical-services'])){
          wp_set_post_terms($post_id,$_POST['technical-services'],'business-category',true);
      if(isset($_POST['travel'])){
          wp_set_post_terms($post_id,$_POST['travel'],'business-category',true);
      if(isset($_POST['venue'])){
          wp_set_post_terms($post_id,$_POST['venue'],'business-category',true);
      }

I have also updated the form with the ID's. See screencapture.

#1182424

Shane
Supporter

Languages: English (English )

Timezone: America/Jamaica (GMT-05:00)

Hi Laurie,

You don't need to add the sub categories individually :).

Secondly you are missing the close brackets on your if statements.

If you notice in my simple example below.

if (isset($_POST['gen-biz-category'])){
            wp_set_post_terms($post_id,$_POST['gen-biz-category'],'business-category');
            if(isset($_POST['animal-care'])){
                wp_set_post_terms($post_id,$_POST['animal-care'],'business-category',true);
            }
        }

My code is properly nested with its respective open and close braces.

Thanks,
Shane

#1182427

Hi Shane,

Still getting the errors.

<?php
toolset_snippet_security_check() or die( 'Direct access is not allowed' );

/**
 * New custom code snippet.
 * Company Name
 * Post ID for Business categories
 */
add_action('cred_save_data', 'set_company_name',10,2);
function set_company_name($post_id, $form_data)
{
    // if a specific form
    if ($form_data['id']=4305)
    {
       $title = get_the_title($post_id);
		update_post_meta($post_id, 'wpcf-company_title',$title);
               wp_set_post_terms($post_id,$_POST['gen-biz-category'],'business-category');
if (isset($_POST['gen-biz-category'])){
            wp_set_post_terms($post_id,$_POST['gen-biz-category'],'business-category');
      if(isset($_POST['animal-care'])){
                wp_set_post_terms($post_id,$_POST['animal-care'],'business-category',true);
	  if(isset($_POST['arts-literature'])){
          wp_set_post_terms($post_id,$_POST['arts-literature'],'business-category',true);
          }
      if(isset($_POST['beauty-spa'])){
          wp_set_post_terms($post_id,$_POST['beauty-spa'],'business-category',true);
          }
      if(isset($_POST['care-coordinator'])){
          wp_set_post_terms($post_id,$_POST['care-coordinator'],'business-category',true);
          }
      if(isset($_POST['childrens-needs'])){
          wp_set_post_terms($post_id,$_POST['childrens-needs'],'business-category',true);
          }
      if(isset($_POST['diversity-multi-cultural'])){
          wp_set_post_terms($post_id,$_POST['diversity-multi-cultural'],'business-category',true);
          }
      if(isset($_POST['education'])){
          wp_set_post_terms($post_id,$_POST['education'],'business-category',true);
          }
      if(isset($_POST['fashion'])){
          wp_set_post_terms($post_id,$_POST['fashion'],'business-category',true);
          }
      if(isset($_POST['food-drink'])){
          wp_set_post_terms($post_id,$_POST['food-drink'],'business-category',true);
          }
      if(isset($_POST['goods-retail'])){
          wp_set_post_terms($post_id,$_POST['goods-retail'],'business-category',true);
          }
      if(isset($_POST['health-wellness'])){
          wp_set_post_terms($post_id,$_POST['health-wellness'],'business-category',true);
          }
      if(isset($_POST['home-garden'])){
          wp_set_post_terms($post_id,$_POST['home-garden'],'business-category',true);
          }
      if(isset($_POST['legal-financial'])){
          wp_set_post_terms($post_id,$_POST['legal-financial'],'business-category',true);
          }
      if(isset($_POST['non-profit'])){
          wp_set_post_terms($post_id,$_POST['non-profit'],'business-category',true);
          }
      if(isset($_POST['professional-services'])){
          wp_set_post_terms($post_id,$_POST['professional-services'],'business-category',true);
          }
      if(isset($_POST['real-estate'])){
          wp_set_post_terms($post_id,$_POST['real-estate'],'business-category',true);
          }
      if(isset($_POST['technical-services'])){
          wp_set_post_terms($post_id,$_POST['technical-services'],'business-category',true);
          }
      if(isset($_POST['travel'])){
          wp_set_post_terms($post_id,$_POST['travel'],'business-category',true);
          }
      if(isset($_POST['venue'])){
          wp_set_post_terms($post_id,$_POST['venue'],'business-category',true);
  }
        }

I see you have 2 opens { in the top section, but no closing, could that be it?

#1182431

Nevermind, figured it out! Thank you... Testing now to make sure everything is ok.