Cannot add php code...
 
Share:
Notifications
Clear all

[Solved] Cannot add php code in theme files

6 Posts
2 Users
0 Likes
667 Views
Posts: 9
 Baze
Topic starter
(@baze)
Active Member
Joined: 2 years ago

Hi guys,

 

i'm trying to embed the users avatar from jReviews into the comments, so i've created template override which works fine in /wp-content/themes/mytheme/wpdiscuz/layouts/1/avatar.html, but then when i add the php code there nothing happens, only the html is rendered. Can you please let me know how can i sort this out?

 

thanks,

Baze

5 Replies
Asti
Posts: 7059
 Asti
Support
(@asti)
Illustrious Member
Joined: 6 years ago

Hello Baze,

Please let us know what code have you added to the file? 

Posts: 9
 Baze
Topic starter
(@baze)
Active Member
Joined: 2 years ago

Any php code is not rendered, not even a simple echo, and currently i have this but on the front end i don't see anything:

<?php
    	require_once ABSPATH.'/wp-content/plugins/jreviews/jreviews/framework.php';
    S2App::import('Component','userprofiles_profile','jreviews');

S2App::import('Model','everywhere_com_content','jreviews');
    $profile = UserprofilesProfileComponent::getOneProfile($userId = null);
    echo $profile;
?>
1 Reply
 Baze
(@baze)
Joined: 2 years ago

Active Member
Posts: 9

So i've just seen that the system actually puts the code in comments, this is the output:

<!--?php
    	require_once ABSPATH.'/wp-content/plugins/jreviews/jreviews/framework.php';
    S2App::import('Component','userprofiles_profile','jreviews');

S2App::import('Model','everywhere_com_content','jreviews');
    $profile = UserprofilesProfileComponent::getOneProfile($userId = null);
    echo $profile;
?-->
Posts: 9
 Baze
Topic starter
(@baze)
Active Member
Joined: 2 years ago

Even this is only showing the avatar and the author name, not the echo

<div class="{AVATAR_WRAPPER_CLASSES}">
    {AVATAR}
   <div class="auth">{AUTHOR}</div>
   <?php echo "baze"; ?>
</div>
1 Reply
Asti
 Asti
Support
(@asti)
Joined: 6 years ago

Illustrious Member
Posts: 7059

@baze,

This is an HTML file, you can't add the PHP file there. You should create some shortcode like {CUSTOM_SHORTCODE}, use the wpdiscuz_comment_end hook and replace the shortcode in the $commentOutput parameter.

Share: