0
votes

I have taken the following code from a tutorial. It is meant to create a shortcode I can use to add a button to my Wordpress posts, which directly sends a message to the user who created the post.

I am getting the php error -

Fatal error: Class 'wpchats' not found in /homepages/22/d688271077/htdocs/clickandbuilds/VillaShare/wp-content/themes/listable/functions.php on line 755

Please see the functions.php code and shortcode below:

add_shortcode('wpc-link-to-chat', function($atts) {

    $a = shortcode_atts( array(
        'user_id' => wp_get_current_user()->ID
    ), $atts );

    $user_id = (int) "{$a['user_id']}";
    $wpchats = new wpchats;
    return $wpchats->get_settings( 'messages_page' ) . "?recipient=$user_id";    
});

Shortcode:

[wpc-link-to-chat user_id="3"]
2
guessing that your class is not declared - where is you class and what does it contain? - Stender

2 Answers

0
votes

Try to use:

...
$wpchats = new wpChats;
return $wpchats->get_settings( 'messages_page' ) . "?recipient=$user_id";
});
0
votes

Maybe it sounds stupid, but if wpChats is a class you should declare it with ()

$wpchats = new wpchats();