{"__v":2,"_id":"56d8888ab159f10b0030464a","category":{"__v":1,"_id":"56d88885b159f10b00304612","pages":["56d8888ab159f10b00304649","56d8888ab159f10b0030464a"],"project":"549a321bf876ae0b00f33623","version":"56d88884b159f10b00304609","sync":{"url":"","isSync":false},"reference":false,"createdAt":"2015-12-31T23:22:56.157Z","from_sync":false,"order":8,"slug":"actions-reference","title":"Actions Reference"},"parentDoc":null,"project":"549a321bf876ae0b00f33623","user":"549a320d5b50c21400fae689","version":{"__v":3,"_id":"56d88884b159f10b00304609","project":"549a321bf876ae0b00f33623","createdAt":"2016-03-03T18:55:00.567Z","releaseDate":"2016-03-03T18:55:00.567Z","categories":["56d88885b159f10b0030460a","56d88885b159f10b0030460b","56d88885b159f10b0030460c","56d88885b159f10b0030460d","56d88885b159f10b0030460e","56d88885b159f10b0030460f","56d88885b159f10b00304610","56d88885b159f10b00304611","56d88885b159f10b00304612","56d88885b159f10b00304613","56d88885b159f10b00304614","56d89250b159f10b003046d4","56da13977222d50b0070167c"],"is_deprecated":false,"is_hidden":false,"is_beta":false,"is_stable":true,"codename":"","version_clean":"2.2.1","version":"2.2.1"},"updates":[],"next":{"pages":[],"description":""},"createdAt":"2016-02-29T17:44:35.430Z","link_external":false,"link_url":"","githubsync":"","sync_unique":"","hidden":false,"api":{"results":{"codes":[]},"settings":"","auth":"required","params":[],"url":""},"isReference":false,"order":1,"body":"[block:api-header]\n{\n  \"type\": \"basic\",\n  \"title\": \"lifterlms_order_process_success\"\n}\n[/block]\nThis action is run at the successful completion of a LifterLMS order before the user is redirected. A copy of the LifterLMS Order that has been placed is passed to the handler function where your function can obtain user, product, and order price information.\n[block:code]\n{\n  \"codes\": [\n    {\n      \"code\": \"<?php // don't include this line when copying\\n\\n/**\\n * Run during a completed LifterLMS transaction for free and paid orders\\n *\\n * A free order will have a $order->total value of 0\\n *\\n * \\n * :::at:::param  obj    $order instance of the LifterLMS Order object\\n * @return void\\n */\\nfunction my_order_process_success( $order ) {\\n\\n\\t// \\n\\t$ltv = get_user_meta( $order->user_id, 'my_customer_liftetime_value', true );\\n\\n\\tif ( !$ltv ) {\\n\\n\\t\\t$ltv = 0;\\n\\n\\t}\\n\\n\\t$new_ltv = floatval( $ltv ) + floatval( $order->total );\\n\\n\\tupdate_user_meta( $order->user_id, 'my_customer_liftetime_value', $new_ltv );\\n\\n}\\nadd_action( 'lifterlms_order_process_success', 'my_order_process_success', 9, 1 );  // this action has to fire before the final order success call that LifterLMS calls natively so the priority must be less than 10\",\n      \"language\": \"php\",\n      \"name\": \"lifterlms_order_process_success.php\"\n    }\n  ]\n}\n[/block]","excerpt":"","slug":"actions-checkout","type":"basic","title":"Actions: Checkout"}
[block:api-header] { "type": "basic", "title": "lifterlms_order_process_success" } [/block] This action is run at the successful completion of a LifterLMS order before the user is redirected. A copy of the LifterLMS Order that has been placed is passed to the handler function where your function can obtain user, product, and order price information. [block:code] { "codes": [ { "code": "<?php // don't include this line when copying\n\n/**\n * Run during a completed LifterLMS transaction for free and paid orders\n *\n * A free order will have a $order->total value of 0\n *\n * \n * @param obj $order instance of the LifterLMS Order object\n * @return void\n */\nfunction my_order_process_success( $order ) {\n\n\t// \n\t$ltv = get_user_meta( $order->user_id, 'my_customer_liftetime_value', true );\n\n\tif ( !$ltv ) {\n\n\t\t$ltv = 0;\n\n\t}\n\n\t$new_ltv = floatval( $ltv ) + floatval( $order->total );\n\n\tupdate_user_meta( $order->user_id, 'my_customer_liftetime_value', $new_ltv );\n\n}\nadd_action( 'lifterlms_order_process_success', 'my_order_process_success', 9, 1 ); // this action has to fire before the final order success call that LifterLMS calls natively so the priority must be less than 10", "language": "php", "name": "lifterlms_order_process_success.php" } ] } [/block]