This support ticket is created Il y a 5 années et 2 mois. 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.
Aucun de nos assistants n'est disponible aujourd'hui sur le forum Jeu d'outils. Veuillez créer un ticket, et nous nous le traiterons dès notre prochaine connexion. Merci de votre compréhension.
Hello. Thank you for contacting the Toolset support.
I would like to know, how you added the edit profile form? Using view? can you please share how you added edit profile form shortcode or you added edit profile form link?
I've simply put the user form shortcode [cred_user_form form='form_name'] in the editor for the page. The page has a Content Template assigned to it which shows the page content to anyone but Guests using the Access shortcode like this:-
I did think I would need a View originally but it appears this isn't necessary (I assume the WordPress rules that a user can only update their own profile - unless they're an administrator - apply).
A different user won't see the contents of the edit form. The hook needs to differentiate between the ID of the Profile being updated and the ID of the user updating it (which will only be Site Admin of course). I don't want to hardcode Site Admin's User ID into the hook hence my question about how I retrieve the ID of the profile in a before_save_data hook.
I understand, but the default behaviour is if you logged in as admin and display the edit user form it will display the currently loggedin user profile form for editing.
I think you need to use edit user form link so that you can display the user form for editing for specific user of your choice. Can I have problem URL and access details so I can check how you configured your form and also tell me what user profile you want to edit with user edit form.
I have set the next reply to private which means only you and I have access to it.
Sorry but the site is locked down so I can't give access.
Would it not just be easier and quicker all round to simply let me know to retrieve the id of the profile in a before_save_data hook and let me worry about the rest??
form_id. The form ID.
post_type. The post type that the form operates on.
form_type. The type of the form (create or edit form.
container_id. Refers to the post_id of the post, page or custom post type that contains the CRED form
and then the before_save_data hook would look like this?:-
add_action('cred_before_save_data', 'ts_before_save_data_form_1990',10,2);
function ts_before_save_data_form_1990($form_data) {
if ($form_data['id']==1990) {
$user_id = $_POST['profileID'];//generic field name
//do something
}
}
However I'm getting an Undefined Index error on 'profileID'. Can you point me in the right direction please?
And added the following hook and when I submit the form, I can see its displaying "user_profile_id".
add_action('cred_before_save_data', 'func_before_sd',10,1);
function func_before_sd($form_data){
// if a specific form
if ($form_data['id']==1990) {
echo "<pre>";
print_r($form_data);
print_r($_POST);
exit;
}
}