Hi,
I'm trying to display an edit user form via a php shortcode but it does not show up.
Here is my function:
function usr_sn_edit_employee() {
$user_id = (isset($_GET['userid'])) ? $_GET['userid'] : '';
return do_shortcode("[cred_user_form form='edit-user' user='".$user_id."']");
}
add_shortcode('usr_sn_edit_employee', 'usr_sn_edit_employee');
In case you wonder, the URL parameter is specified: "/edit-user/?userid=4".
The same code with an edit post form works fine, but the user form does not want to display anything in this configuration.
I tried it on two different sites, one is almost empty, so I think you will be able to replicate it.
I have only Toolset Types and Forms, neither Views, nor Access modules are installed.
Please check.
Thank you
Actually, nothing is displayed even if I don't use php and use your shortcode:
[cred_user_form form='edit-user' user='4']
It seems it only wants to display the form if I choose to edit my own profile, not somebody's else.
Thank you for looking into it.
Minesh
Supporter
Idiomas:
Inglés (English )
Zona horaria:
Asia/Kolkata (GMT+05:30)
Hello. Thank you for contacting the Toolset support.
What if you try to use the Toolset form's PHP function to render the form:
echo cred_user_form($form_id,$user_id);
More info:
=> https://toolset.com/documentation/programmer-reference/forms/cred-shortcodes/#cred_user_form
Hi Minesh,
It's good to know I can do that, however, as I said, the form is only displayed if I choose my own ID. It does not allow to edit other users.
Please try to replicate, I'm sure you'll see the same.
Minesh
Supporter
Idiomas:
Inglés (English )
Zona horaria:
Asia/Kolkata (GMT+05:30)
Does the user has rights to edit other users information?
Can I review your setup please? Can you please share admin access details for admin user as well as the user currently you are using.
I have set the next reply to private which means only you and I have access to it.
Minesh
Supporter
Idiomas:
Inglés (English )
Zona horaria:
Asia/Kolkata (GMT+05:30)
I just installed and activated the Toolset Access plugin as to edit other users with a Toolset Form you must use it in combination with Access.
I can see it working as expected. Can you please confirm it works at your end as well.
I don't want to use Access. I don't need it and don't want to install it for this only purpose.
The form should be available without it, it's not so complicated. I consider it a bug. Can you please contact your developers about it?
Thank you
Installing Access only adds me the hussle to go in the settings for every form I create to enable it for different user roles. I have more than 20 forms on some sites. It's super annoying.
Please contact your developers.
Thank you
Minesh
Supporter
Idiomas:
Inglés (English )
Zona horaria:
Asia/Kolkata (GMT+05:30)
I checked with our Devs and fortunately there is a workaround.
You can use the following filter to grant access to the administrator users:
function func_grant_access_to_edit_user_form($bool ,$form_id,$user_data) {
if ( current_user_can( 'manage_options' ) ){
$bool = true;
}
return $bool;
}
add_filter('toolset_forms_current_user_can_use_user_form', 'func_grant_access_to_edit_user_form',11,3);
You should try to add the above code to "Custom Code" section offered by Toolset or to the functions.php file of your theme.
=> https://toolset.com/documentation/programmer-reference/adding-custom-code/using-toolset-to-add-custom-code/#adding-custom-php-code-using-toolset