• Resolved pewpew41

    (@pewpew41)


    Hi all,

    If I am on a membership checkout page for a level ID of 1 (i.e. mydomain.com/membership-account/membership-checkout/?level=1), how can I return this level ID (1) in a code? I’ve tried $pmpro_level->id, but it returns null on my code snippet.

Viewing 3 replies - 1 through 3 (of 3 total)
  • Plugin Author Andrew Lima

    (@andrewza)

    Hi @pewpew41

    Thank you for reaching out to Paid Memberships Pro.

    You can also get the ID from the query parameter by doing $_REQUEST['level'] when all else fails.

    What hook are you using to try and get the level ID? Did you set the global $pmpro_level; within your code snippet?

    If you need help with a custom code snippet, please reach out to a local WordPress developer or post to https://jobs.wordpress.net

    Thread Starter pewpew41

    (@pewpew41)

    Thanks for that. I have the level ID now.

    I’m using the pmpro_checkout_after_level_cost hook and want to grab the numerical cost amount from the “The price for membership is …” statement – any advice on how to do that?

    I did the below, but it’s still showing $0.00:

    global $pmpro_level;
    
    function test_message( ) {
    		$pmpro_level = $_REQUEST['level'];
    		$level = pmpro_getLevel( $pmpro_level );
    		$level = pmpro_filter_price_for_text_field( $level->billing_amount );
    		$level = pmpro_formatPrice( $level );
    		echo "$level";
    }
     add_action( 'pmpro_checkout_after_level_cost', 'test_message' );
    Thread Starter pewpew41

    (@pewpew41)

    Marked as resolved – I have figured this out myself.

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

The topic ‘Checkout page: Grab membership level ID from current checkout page’ is closed to new replies.