Simple Membership Plugin › Forums › Simple Membership Plugin › Error in SwpmMemberUtils
- This topic has 4 replies, 4 voices, and was last updated 7 years, 1 month ago by
The Assurer.
-
AuthorPosts
-
October 10, 2019 at 10:15 am #19081
Anonymous
InactiveHello,
I use the following code to check if a member is logged in or not,<?php if(SwpmMemberUtils::is_member_logged_in()) { ?>But I receive this error when I refresh the site: (I inserted … instead of site and some directories name to be shorter)
Fatal error: Uncaught Error: Class ‘pmMemberUtils’ not found in /home/…(THE FILE THAT I ADD THIS CODE)… Stack trace: #0 /home/…/public_html/wp-includes/template.php(724): require() #1 /home/…/public_html/wp-includes/template.php(671): load_template(‘/home/…, false) #2 /home/…/public_html/wp-includes/general-template.php(168): locate_template(Array, true, false) #3 /home/…/public_html/wp-content/themes/…/index.php(24): get_template_part(‘template-parts/…’) #4 /home/…/public_html/wp-includes/template-loader.php(78): include(‘/home/…) #5 /home/…/public_html/wp-blog-header.php(19): require_once(‘/home/…) #6 /home/…/public_html/index.php(17): require(‘/home/…) #7 {main} thrown in /home/…/public_html/wp-content/themes/….php on line 8
October 10, 2019 at 11:58 am #19082mbrsolution
ModeratorHi, your code is wrong. Please try the following code. Let me know how you go.
<?php if(SwpmMemberUtils::is_member_logged_in()) { ?> //Your message for logged-in members goes here <?php } ?>Thank you
October 10, 2019 at 4:24 pm #19083Anonymous
InactiveSorry, I did not write complete my code.
My code have exactly the same structure that you said. but I receive the above error.October 11, 2019 at 1:14 am #19086admin
KeymasterTroubleshooting custom code is not something we can look at here (it is beyond the scope of this free support forum). From looking at the error, I can see that the custom script is trying to reference the following class:
pmMemberUtilsThat will be an issue since the name of the full class is “SwpmMemberUtils”. So you should check your code to make sure there is no unwanted empty space characters or hidden line breaks in your code (something that got introduced from the copy & paste operation)
October 12, 2019 at 12:10 am #19087The Assurer
ModeratorIt “might help” if you told us the super-secret file names used in your paths. Any files that define classes must be parsed first, before they can be invoked. As a debugging aid, maybe you can do a ckass_exists() test in the code as a breakpoint?
-
AuthorPosts
- You must be logged in to reply to this topic.