Skip Navigation

[Gelöst] Pass URL parameter in User Fields using custom shortcode

Dieser Thread wurde gelöst. Hier ist eine Beschreibung des Problems und der Lösung.

Problem:
Pass URL parameter in User Fields using custom shortcode

Solution:
When you use custom shortode as Types shortcode's attribute argument, you need to register the custom shortcode at:
=> Toolset => Settings => Frontend content Tab => Third-party shortcode arguments.

You can find the proposed solution, in this case, with the following reply:
https://toolset.com/forums/topic/pass-url-parameter-in-user-fields/#post-1174107

Relevant Documentation:
https://toolset.com/documentation/user-guides/shortcodes-within-shortcodes/#third-party-shortcode-arguments

This support ticket is created vor 5 Jahren, 11 Monaten. 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.

Heute stehen keine Supporter zur Arbeit im Werkzeugsatz-Forum zur Verfügung. Sie können gern Tickets erstellen, die wir bearbeiten werden, sobald wir online sind. Vielen Dank für Ihr Verständnis.

Sun Mon Tue Wed Thu Fri Sat
- 10:00 – 13:00 10:00 – 13:00 10:00 – 13:00 10:00 – 13:00 10: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: Asia/Kolkata (GMT+05:30)

Dieses Thema enthält 7 Antworten, hat 2 Stimmen.

Zuletzt aktualisiert von burakA vor 5 Jahren, 11 Monaten.

Assistiert von: Minesh.

Author
Artikel
#1174072

Hello,
I try to create a user profile page. This page should show the current user details by default but if the user is an admin it should show the data of an id.

I tried to pass an id parameter through the URL and wrote a shortcode:

add_shortcode( 'get_url_param', 'url_param');
function url_param(){
if(!$_GET['id']){
return;
}else{
return $_GET['id'];
}
}

Than i tried to implement this in the view:
[toolset_access role="Administrator,Super User" operator="allow"]
[wpv-user field="user_email" id="[get_url_param]"]
[/toolset_access]
[toolset_access role="Administrator,Super User" operator="deny"]
[wpv-user field="user_email"]
[/toolset_access]

Sadly it wont display the user_email by id.

#1174073

Minesh
Supporter

Sprachen: Englisch (English )

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

Hello. Thank you for contacting the Toolset support.

Well - if you want to display the current user information, why don't you use the view's shortcode: [wpv-current-user]

For example:

[wpv-current-user info="email"]

More info:
=> https://toolset.com/documentation/user-guides/views-shortcodes/#wpv-current-user

#1174074

Hello Minesh,
thank you for the quick response. I want to give "admin" and "super-user" the possibility to see the profiles of other registered users.

#1174075

Minesh
Supporter

Sprachen: Englisch (English )

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

Could you please share the problem URL where you are trying to display the email?

*** Please make a FULL BACKUP of your database and website.***
I would also eventually need to request temporary access (WP-Admin and FTP) to your site. Preferably to a test site where the problem has been replicated if possible in order to be of better help and check if some configurations might need to be changed.

I would additionally need your permission to de- and re-activate Plugins and the Theme, and to change configurations on the site. This is also a reason the backup is really important. If you agree to this, please use the form fields I have enabled below to provide temporary access details (wp-admin and FTP).

I have set the next reply to private which means only you and I have access to it.

#1174087

Minesh
Supporter

Sprachen: Englisch (English )

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

Well - I see there is a Layout created to display the single user profile:
=> versteckter Link

I do not see the code you shred:

[toolset_access role="Administrator,Super User" operator="allow"]
[wpv-user field="user_email" id="[get_url_param]"]
[/toolset_access]
[toolset_access role="Administrator,Super User" operator="deny"]
[wpv-user field="user_email"]
[/toolset_access]

Could you please tell me where exactly you added above code? Where I can see it?

And one test link where I can check the URL param to get the admin ID?

#1174088
screen_2.jpg
screen_1.jpg

Its hard for me to describe it so i made screenshots

versteckter Link

#1174107

Minesh
Supporter

Sprachen: Englisch (English )

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

Could you please check now, I've adjust the code as given under:

As you can see I adjust the "super_user " role as well as when you use the Types shortcode to display the "usermeta" - you need to pass the user_id.

<p>[toolset_access role="Administrator,super_user" operator="allow"]<br />
[wpv-user field="user_email" id="[get_url_param]"]<br />
[/toolset_access]</p>

<p>[toolset_access role="Administrator,super_user" operator="allow"]<br />
[types usermeta='niederlassungsform' user_id="[get_url_param]"][/types]<br />
[/toolset_access]<br />

In addition to above modifications, I've registered the shortcode [get_url_param] at:
=> Toolset => Settings => Frontend content Tab => Third-party shortcode arguments.

More info:
=> https://toolset.com/documentation/user-guides/shortcodes-within-shortcodes/#third-party-shortcode-arguments

I can see it outputs the email and niederlassungsform field value:
=> versteckter Link

#1174109

My issue is resolved now. Thank you!