Skip Navigation

[Resolved] problem using USERPRO plugin with toolset

This support ticket is created 7 years, 9 months ago. There's a good chance that you are reading advice that it now obsolete.

This is the technical support forum for Toolset - a suite of plugins for developing WordPress sites without writing PHP.

Everyone can read this forum, but only Toolset clients can post in it. Toolset support works 6 days per week, 19 hours per day.

Sun Mon Tue Wed Thu Fri Sat
- 9:00 – 13:00 9:00 – 13:00 9:00 – 13:00 9:00 – 13:00 9:00 – 13:00 -
- 14:00 – 18:00 14:00 – 18:00 14:00 – 18:00 14:00 – 18:00 14:00 – 18:00 -

Supporter timezone: Asia/Hong_Kong (GMT+08:00)

Tagged: 

This topic contains 22 replies, has 2 voices.

Last updated by shirlyk 7 years, 8 months ago.

Assisted by: Luo Yang.

Author
Posts
#411044

I am trying to: create a "chat with me" button between logged-in user and post author of a post in a loop. i'm using USERPRO chat plugin fir that.

I expected to see: a chat window is suppose to popup in a modal, but nothing happens and i get an error in the console:

userpro-msg.js?ver=4.4.4:40 Uncaught TypeError: Cannot read property 'html' of null 

it happens only using your theme and inside a views loop....

Instead, I got: nothing.

#411216

Dear shirly,

Since it is a compatibility problem, could you post a downloadable URL for the USERPRO plugin, and describe detail steps to duplicate same problem?

I need test and debug it in my localhost, thanks

#411360

Hi Lou,
is it possible to open a privet reply for me so I could post you a link for the plugin? I've purchased it.

here are the steps of what I did:

1. I've created an "ads board" on my website so people could add their ad and other users could send them a privet message.
2. the messaging system is based on 2 plugins: "UserPro" and an extension of this plugin called "Private Messages".
3. the idea is that once I've installed "Private Messages" - I add a code in order to add a "chat now" button:

<a href="#" class="userpro-button chat userpro-init-chat" data-chat_with="1" data-chat_from="2"><i class="userpro-icon-comment"></i>Message me now!</a>

Here, 'data-chat_with="1" ' is the id of admin

so what I've tried to do on my website is to create a view that shows the ads that have been published. inside the loop- I implemented this code:

       <a href="#" class="userpro-button chat userpro-init-chat" data-chat_with="[wpv-post-author format='meta' meta='ID']" data-chat_from="[wpv-current-user info='id']"><i class="userpro-icon-comment"></i>Message me now!</a>

The thing is that when I click on the button- it looks like something is going to happen (I get a gray layer on the screen and a loading icon) but eventually- nothing happens....

i would really appreciate if you could help.

thank you 🙂

#411607

OK, please fill below private detail box with the downloadable URL of USERPRO plugin, thanks

#411940
655.JPG
654.JPG

Thanks for the details, I tried these in my localhost, please correct me if there is anything missing:
1) Install Views + UserPro + userpro-messaging
I see a warning message:
You are using a trial version of UserPro plugin

2) Create a view to list posts, in views loop section, add the codes you mentioned above:

<a href="#" class="userpro-button chat userpro-init-chat" data-chat_with="[wpv-post-author format='meta' meta='ID']" data-chat_from="[wpv-current-user info='id']"><i class="userpro-icon-comment"></i>Message me now!</a>

3) put above view into a page, and view it in front-end, I see below screenshot 654.JPG,
Here is what I found:
1) There is a JS error, which produced by userpro-messaging plugin:
userpro-msg.js?ver=4.5.3:296 Uncaught TypeError: jQuery(...).smartresize is not a function

2) I checked the HTML source codes, see screenshot 655.JPG:
Views does output correct author ID and current user ID into the HTML A tag, for the problem you mentioned above, I suggest you ask help from the plugin author of userpro-messaging.

#414904
chat-btn.png

thank you Luo,
could you try and help me add a chat to my website in another way?

i'm trying the wp-chats plugin. it has a tutorial that suggest a php code that adds a chat button to each post to let the current logged in user chat with the author of the post that they’re viewing.

is there a way to take this code and add it to a post in a view loop and this way to solve my problem?
this is the tutorial: hidden link

and this is their code:

if ( !function_exists('se_start_chat_btn_by_user') ) :;
function se_start_chat_btn_by_user( $user_id ) {
    global $current_user;
    if ( ! $current_user->ID || ! $user_id || $current_user->ID == $user_id ) return;
    ob_start(); wp_title(); $title = ob_get_clean();
    $userdata = get_userdata( $user_id );
    ?>
         <div class="wpc-start-chat">
            <?php wpc_contact_user_modal_link(
                $userdata,
                array(
                    'exit_title' => $title,
                    'link_text' => sprintf('Start chat with %s', $userdata->display_name)
                )
            ); ?>
        </div>
    <?php
}
endif;
 
 
add_filter('the_content',function($content) {
    if ( is_single() ) {
        global $post;
        ob_start();
        se_start_chat_btn_by_user( $post->post_author );
        $content .= ob_get_clean();
  
    }
    return $content;
});

i attached a sample of what i'm aiming to do.

thank you 🙂

#414999

Thanks for the details, I am checking it in your test site, will feedback if there is any found.

#415321

Please try this:
1) Add below codes into your theme/functions.php:


add_shortcode('start_chat_btn_by_user', 'start_chat_btn_by_user_func');
function start_chat_btn_by_user_func($atts){
	$user_id = get_the_author_id();
    global $current_user;
	$res = '';
    if ( ! $current_user->ID || ! $user_id || $current_user->ID == $user_id || !function_exists('wpc_contact_user_modal_link') ) return;
	ob_start();
	$userdata = get_userdata( $user_id );
    ?>
         <div class="wpc-start-chat">
            <?php wpc_contact_user_modal_link(
                $userdata,
                array(
                    'exit_title' => $title,
                    'link_text' => sprintf('Start chat with %s', $userdata->display_name)
                )
            ); ?>
        </div>
    <?php
	$res .= ob_get_clean();
	return $res;
}

2) Use above shortcode in the view's loop:
[start_chat_btn_by_user]

It is only an example, for your reference.

#415430

hi,
thanks 🙂

i'v added the code to the function.php and put the shortcode in my VIEW loop. but i don't see any button on my site, where i've putted the shortcode.

#415685

As I mentioned above, it is only an example, you will need to activate the wp-chats plugin first, and test again, if the problem still exists, since it is a custom codes problem, please duplicate same problem in a test site, and fill below private detail box with login details and ftp access, also point out the problem page URL and where I can edit your PHP codes, I need test and debug it in a live website, thanks

#419495

Thanks for the details, checking it in your website.

#419497

The "WordPress access details:" you provided, seems is a subscriber user, do debug this problem, please setup it as a admin user, and also point out the problem page URL and where I can edit your PHP codes, thanks

#419641

sorry 🙂
took care of it.

thanks!

#419812

Thanks for the details, since you did not point out the problem page URL, so I create a post here:
hidden link
View here:
hidden link
And modify the PHP codes as below:

add_shortcode('start_chat_btn_by_user', 'start_chat_btn_by_user_func');
function start_chat_btn_by_user_func($atts){
    $author_id = get_the_author_id();
    $current_user_id = get_current_user_id();
    $res = '';
    if ( ! $current_user_id || $current_user_id  == $author_id ) return;
    $userdata = get_userdata( $author_id );
    ob_start();
    ?>
         <div class="wpc-start-chat">
            <?php wpc_contact_user_modal_link(
                $userdata,
                array(
                    'exit_title' => $title,
                    'link_text' => sprintf('Start chat with %s', $userdata->user_login)
                )
            ); ?>
        </div>
    <?php
    $res .= ob_get_clean();
    return $res;
}

Please test again, check if it is want you want

#419845

hi there,
thank you!

but i see that you have changed the theme. it was toolset starter and you changed it to Twenty Sixteen.
When i copy the code to the Toolset Starter function.php - the code does not work.

any idea why?

thanks 🙂

This ticket is now closed. If you're a WPML client and need related help, please open a new support ticket.