Skip Navigation

[Gelöst] Using Shortcode in custom Code of toolset

This support ticket is created vor 3 Jahren, 8 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 1 Antwort, hat 2 Stimmen.

Zuletzt aktualisiert von Minesh vor 3 Jahren, 8 Monaten.

Assistiert von: Minesh.

Author
Artikel
#1993321

Tell us what you are trying to do?

Hey there i do have a custom function in toolset settings.
The function itself is working great, so there is no Problem.

The Problem is using a toolset shortcode in it.
When i take a look on the front end the shortcode is only visible as words and not the executed code!

Here is my code:

function test_add_button_in_members_loop() {
if ( bp_get_member_user_id() == bp_loggedin_user_id() ) {
  return;
}
?>
[wpv-user field="user_email"] //this  shortcode shows just the text and not the user email

  <div id="block-a-member" class="generic-button">
    <a data-balloon-pos="down" data-balloon="TEST" href="/members/" class="block-member">Another Button</a>
  </div>
<?php
}
add_action( 'bp_member_members_list_item', 'test_add_button_in_members_loop' );

Do you know what i am doing wrong here?
Cheers

#1993405

Minesh
Supporter

Sprachen: Englisch (English )

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

Hello. Thank you for contacting the Toolset support.

Shortcode needs to rendered first before it gets displyed, what if you try to use the global current user variable.

For example:

function test_add_button_in_members_loop() {
if ( bp_get_member_user_id() == bp_loggedin_user_id() ) {
  return;
}

echo do_shortcode('[wpv-user field="user_email"]');  //this  shortcode shows just the text and not the user email
?>

 
  <div id="block-a-member" class="generic-button">
    <a data-balloon-pos="down" data-balloon="TEST" href="/members/" class="block-member">Another Button</a>
  </div>
<?php
}
add_action( 'bp_member_members_list_item', 'test_add_button_in_members_loop' );

Does this works?