latest stable versions: v150827 (changelog)

Old Forums (READ-ONLY): The community now lives at WP Sharks™. If you have an s2Member® Pro question, please use our new Support System.

Code to display N/A if constant returns null

Home Forums Community Forum Code to display N/A if constant returns null

This topic contains 2 replies, has 2 voices. Last updated by  Ryan Black 4 years, 5 months ago.

Topic Author Topic
Posted: Monday Jul 23rd, 2012 at 11:31 pm #20029
Ryan Black
Username: mrjack92

Hi,

I’m working on creating a page that will display the profile summary for a user that is logged in.

Things like the username, payment subscr. gateway, EOT expiration, etc.

I would like to add some kind of code to this page, that if one of these PHP constants returns null (i.e the user does not have a former payment date), then it will display something like “N/A” or whatever text I decide to put in there.

Any assistance with this would be greatly appreciated. Thanks.

List Of Topic Replies

Viewing 2 replies - 1 through 2 (of 2 total)
Author Replies
Author Replies
Posted: Tuesday Jul 24th, 2012 at 9:08 pm #20123
Eduan
Username: Eduan
Moderator

Hello Ryan,

Have you checked under Dashboard -› s2Member® -› API / Scripting -› PHP/API Constants?

Hope this helps. :)

Posted: Thursday Jul 26th, 2012 at 11:50 pm #20363
Ryan Black
Username: mrjack92

Found the solution, was a lot simpler than I figured.

<?php

$str= S2MEMBER_CONSTANT;

if (empty($str)) {
    echo "N/A";
} else {
    echo S2MEMBER_CONSTANT;
} 

?>

Replace “S2MEMBER_CONSTANT” with whatever function you’re checking. Hope this helps anyone else trying to do the same.

  • This reply was modified 4 years, 5 months ago by  Ryan Black.
Viewing 2 replies - 1 through 2 (of 2 total)

This topic is closed to new replies. Topics with no replies for 2 weeks are closed automatically.

Old Forums (READ-ONLY): The community now lives at WP Sharks™. If you have an s2Member® Pro question, please use our new Support System.

Contacting s2Member: Please use our Support Center for bug reports, pre-sale questions & technical assistance.