Skip Navigation

[Resolved] Empty Select fields on CRED User forms for Edit existing user

This support ticket is created 4 years, 7 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.

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

Supporter timezone: Africa/Casablanca (GMT+01:00)

This topic contains 4 replies, has 3 voices.

Last updated by Jamal 4 years, 7 months ago.

Assisted by: Jamal.

Author
Posts
#1828535
cred-user-form-default-feld-value.png
cred-user-form-empty-value.png
user-edit-screen.png

I am trying to:
Create a custom page to streamline editing specific users based on their associated programs.

Link to a page where the issue can be seen:
I created a custom WordPress admin page, which takes a user_id parameter and generates a Toolset CRED User Form using the PHP snippet.

$form_id = 'Admin ITP';
$user_id = isset($_GET['user_id']) ? $_GET['user_id'] : get_current_user_id();
cred_user_form($form_id,$user_id); 

The CRED user form fields look like this:

[cred_field field="itp-stream" force_type="field" class="form-control" output="bootstrap"]

When editing a user with values already set for Select fields the form shows either the default preset value for a new user OR the -- Select -- even when the user has values already present (the values ARE visible in the /wp-admin/user-edit.php page)

I expected to see:
The current values for the existing user displayed as the selected options in the Select lists.

Instead, I got:
Empty selections or the field default values.

#1829795

Minesh
Supporter

Languages: English (English )

Timezone: Asia/Kolkata (GMT+05:30)

Hello. Thank you for contacting the Toolset support.

As I understand, you have created the Edit User (profile) form using Toolset User form and that form you are displaying using the Form's PHP API function cred_user_form().

Your concern is when you edit the user profile from admin, you have custom select dropdown field from where you set specific option and now when you edit the same user using the Toolset form that custom select dropdown field do not display the option as selected option which you set from editing the user profile from admin - correct?

If yes: I will require access details as well as link of the page where you added the user form.

#1831999

Minesh is on vacation this week. If you don't mind, I'll continue with you on this thread.

Toolset forms are meant to be used on the frontend, using them on the backend is not a supported feature. In fact, I created a private page and used the form on it, the issue was not reproduced. Check it here hidden link
Some fields, like ID, were not rendered. But that's another issue, that we can handle later.

To confirm, if this is a supported feature, let me ask our developers about it, and I will get back to you as soon as possible.

#1832171

Hi Jamal,

Thanks for jumping in, can we verify this works using the PHP API to make sure this works, because I need to be able to set which User ID to Edit in the URL as this will be a "Management Page" for Admin's to review "other" users.

With the current method of using the Shortcode on the front-end it's only changing the current logged in user, and there's no easy way to make the user_id dynamic in the current approach to match my use case.

I would really like it to work within the Admin because then I can rely and making "Admin" functionality central within the WordPress admin, otherwise I'll need to figure how to make users with certain capabilities use the User edit form on the front-end which seems like working around a core issue.

Any help from the developers would be greatly appreciated, I understand this might be more of an edge case, however User forms that edit other users would likely be something very common within an Admin, not so much within the Front-End.

Thanks!

#1832973

Hello Carl,

Our developers confirmed that we have some checks against a form being used on the frontend before running some code. As a general rule, the forms are supposed to be used in the frontend.

You can still pass an ID to the form from the URL parameters, using the wpv-search-term shortcode. I created a new user to demonstrate it, check this URL hidden link
https://toolset.com/documentation/programmer-reference/views/views-shortcodes/#vf-214940

As a workaround, I suggest that you use the form on a regular WordPress page, then use it on an Iframe in your admin area page. You can then, add a Javascript code to the form that will check that it is being on an Iframe, otherwise, redirect to the admin area page. Check this hidden link.
Does it make sense?

I hope this helps. Let me know if you have any questions.