• Resolved wouthaksteen

    (@wouthaksteen)


    I am experiencing some issues with the [wpuf-sub-info] shortcode. When I add it to my page, it shows up on the frontend on the top left of the page instead of where I put the shortcode.

    Therefore I want to write some custom PHP code myself to output the pack info on the frontend. Could someone provide me the PHP functions I need for this (like how to get the current pack name, price and amount of posts left)? I can’t seem to find them in the plugin files (I’m kind of a noob in PHP). Thanks!

Viewing 5 replies - 1 through 5 (of 5 total)
  • Hello @wouthaksteen

    I am experiencing some issues with the [wpuf-sub-info] shortcode

    → Firstly, please note the right shortcode is [wpuf_sub_info] and here is a output from my testing site/page after inserting- https://prnt.sc/1gpab7n. It should working fine.

    Besides, you can look into these files/functions references to know how to get current_users subscription packs info.

    /wp-content/plugins/wp-user-frontend/class/subscription.php shortcode > 
    wpuf_sub_info & wpuf_sub_pack.
    function reference subscription_info() line 746 and subscription_packs() line 757

    /wp-content/plugins/wp-user-frontend/includes/class-user-subscription.php function reference current_pack() line no 51-66

    I hope this will helps.
    Thanks.

    Thread Starter wouthaksteen

    (@wouthaksteen)

    Thanks for the help. I have tried looking into the code but I cannot seem to find a way to print the info using a PHP snippet. For example, if I would want to print the pack name from the php snippet, do you know how I should do that?

    Something along the lines of

    <?php
    $current_user_id = get_current_user_id();
    $sub_pack = wpuf_get_current_sub( $current_user_id );
    
    echo $sub_pack;
    ?>

    Hi again,

    If you want to print Sub Info through PHP then you can use do_shortcode method like:

    <?php
        echo do_shortcode ('[wpuf_sub_info]');
    ?>

    For further developer information, please reach our devs through our GitHub channel.
    Thanks!

    Thread Starter wouthaksteen

    (@wouthaksteen)

    What I am trying to accomplish is something where I can customize what text to show the user. So I want to show them the following sentence:

    ‘You currently have X posts left.’

    In PHP that would translate to

    <?php
    $posts_left = some_function();
    
    echo "<p>You currently have {$posts_left} posts left.</p>";
    ?>

    So essentially what I’m asking is; what php function do I need to get the amount of posts/products left as a variable in php?

    Thread Starter wouthaksteen

    (@wouthaksteen)

    Do you have any idea how this is possible? The shortcode just doesn’t work for me, even after disabling all plugins and custom css/php. It shows up on the top left, outside of the row and column I have put the code into. It is unusable at the moment.

    See how it looks for yourself. https://prnt.sc/1iosmrt.

    I would like to place it underneath the title ‘subscriptions’ but somehow the info is put at the top of my page.

    Thanks in advance!

Viewing 5 replies - 1 through 5 (of 5 total)

The topic ‘Subscription pack info PHP variables’ is closed to new replies.