Support » Plugin: WP Delete User Accounts » shortcode in template

  • Resolved arsenalemusica

    (@arsenalemusica)


    I needed to have my delete button in a template, so I added it like this
    <?php echo do_shortcode(“[shortcode]”); ?>
    but it doesn’t work and it shows the shortcode text
    Do you have any suggestion?

Viewing 10 replies - 1 through 10 (of 10 total)
  • arsenalemusica

    (@arsenalemusica)

    any help here?
    I have succeeded in adding the shortcode in the template, I even added my css class to it, like

    
    <a tooltip="warning message" class="mybtn"><?php echo do_shortcode('[wp_delete_user_accounts label="" button_text="delete account"]'); ?></a>

    but it makes no action whatsoever. Any tips?

    Plugin Author Ren Ventura

    (@renventura)

    Hi, there. Without seeing your site to know for sure, I can only speculate, but I’d guess this is because the assets are not being loaded on your frontend. By default, the plugin doesn’t load the required Javascript unless the current page has the [wp_delete_user_accounts] shortcode. This means that echoing the shortcode in your template is only one of the steps required for making it work outside of a page’s content.

    To manually load the assets on the frontend, you’ll need to use the wp_delete_user_accounts_load_assets_on_frontend filter. For an example, you can refer to the plugin’s Github page. https://github.com/renventura/wp-delete-user-accounts#hooks.

    Hopefully that helps!

    Hello Ren, I cannot show you where the shortcode would be placed because it’s inside a registered user’s account page.
    The first thing I need to do is format the button, because the one above is not really perfect, and I also tried this version
    <a tooltip="warning message" class="mybtn" href="<?php echo do_shortcode('[wp_delete_user_accounts label="" button_text="delete account"]'); ?>"></a>
    but I have doubts.
    Also, creating a custom button template is beyond my skill, so I couldn’t possibly test that filter you mentioned.
    Can you give advice to a non-developer like me?

    Plugin Author Ren Ventura

    (@renventura)

    No need to create a new template. You likely only need to load the Javascript. Try adding this snippet to your functions.php file.

    
    add_filter( 'wp_delete_user_accounts_load_assets_on_frontend', 'wp_delete_user_accounts_load_assets_on_frontend' );
    function wp_delete_user_accounts_load_assets_on_frontend( $load ) {
    	return true;
    }
    
    • This reply was modified 9 months, 4 weeks ago by Ren Ventura.

    Sorry for the very late reply Ren. I have added your filter and it seems that the javascript alert is loading fine (I need to translate it though). But I must have some conflict with the CSS because it’s not rendering the classes as it should (using the code above). Is there an alternative format for the shortcode when inserted in a template?

    Plugin Author Ren Ventura

    (@renventura)

    If you’d like, send me a private message, and I can take a look. I’ll need wp-admin credentials, and a link to the page on which this should be working. You can send me a message via my website, https://renventura.com.

    …I’m testing a few options… I’ll get back to you once I found the solution, or if I haven’t 🙂

    Hello Ren, I think we could solve this without logging into my site.
    I have used this format to include the shortcode in the template:

    <a tooltip="my-custom-text"><?php echo do_shortcode('[wp_delete_user_accounts button_text="eliminazione account"]'); ?></a>

    but you can see from this screenshot that:
    1) there is a text (“this will cause…”) that doesn’t go away, it’s part of the button, i.e. tooltip appears also when hovering on it
    2) I added .po/.mo files in my /language folder but the translation in the modal box is not showing up
    3) question: can I change the confirmation word (DELETE) with one of my choice, via .po translation?

    What am I doing wrong?

    ok Ren, I managed to eliminate the text in (1) by commenting <p><?php echo $label; ?></p> in shortcode-wp_delete_user_accounts.php.

    I have also overcome the (2) translation issues by changing the strings in wp-delete-user-accounts.php but I’d rather have the .po file working.

    In the same section I can read ‘confirm_text’ => $confirm_text which might be the DELETE word I wish to change (3). How can I do that?

    If you have better suggestion for all above I’m looking forward to your advice.

    Plugin Author Ren Ventura

    (@renventura)

    For the text in the shortcode-wp_delete_user_accounts.php file, you can override the file using the wp_delete_user_accounts_shortcode_template filter. Just return a new path to your custom file. This will allow you to modify the markup however you wish. See includes/frontend.php, line 54.

    For translating, I recommend using a plugin like Loco Translate. You can also filter the word DELETE that’s used as the *confirm_text* by using the wp_delete_user_account_confirm_delete_text filter. See wp-delete-user-accounts.php, line 140.

Viewing 10 replies - 1 through 10 (of 10 total)
  • The topic ‘shortcode in template’ is closed to new replies.