Private Messaging Not Working

Hello. I just installed this plugin, and I can't seem to get it to work. When I enter a name in the Send To field, it never finds the user. If I use the [pm_user] shortcode like this: [pm_user user_id=10, the modal never sends and closes.

Any suggestions how I might correct this issue?

  • Ken Kimbrell

    Hello David-

    Sorry for the late response, I have been working on an out of box solution to what you are trying to accomplish. Our Private Messaging does have some out of the box shortcodes that you can add to make the "Message Me" button more unique. Unfortunately some parts of the shortcode do require you to define in your functions php. For example the option to dynamically pull the user_id or user_name must be defined and placed in the php file that you are wanting to call the Private Message. See image below:

    I took the liberty of creating an out-of-box solution to what you are trying to accomplish. As you can see in the image above with the text property you can add to the shortcode text="PM Me :wink:" and that would change the value of the text inside the PM button. See the results below:

    Like it? :stuck_out_tongue_closed_eyes:

    Well just apply this code into your functions.php file and add this shortcode [pm_me] anywhere you want the pm button to appear. As you can see where it says Hello, $variable there is a variable that will dynamically pull the display_name of the user currently viewing the page where the button resides. I also added custom CSS inside the function, its not entirely recommended. I just did it to provide an out of box solution. I do recommend if you want to move the CSS to your current child's theme style.css or a plugin like simple CSS so that when you update your theme it is not overwritten.

    Here is the actual custom code you will need to add to your functions.php file:

    //////////////////////////////////
    // Adding custom shortcode
    /////////////////////////////////
    
    function custom_private_messaging(){
    
    $display_name = wp_get_current_user();
    $current_user = get_current_user_id();
    $pmshortcode  = do_shortcode('[pm_user user_id="'. $current_user .'" subject=""]');
    
    	echo    '<style>
    		        .ig-container .btn.disabled, .ig-container .btn[disabled],
                             fieldset[disabled] .ig-container .btn {
    
    			        cursor: pointer;
    	    		        pointer-events: auto;
    
    			}
    			.align_pm_button,.pm_display_name{
    
    			       text-align:center;
    
    			}
                  </style>';
    
    	echo 	'<div class="pm_display_name"> Hello, ' . $display_name->display_name . '! </div>';
    	echo 	'<div class="align_pm_button">' . $pmshortcode . '</div>';
    
    }
    
    //Just add [pm_me] as a shortcode and get the current users dispaly name
    add_shortcode('pm_me', 'custom_private_messaging');
    
    //////////////////////////////////
    // Adding custom shortcode
    /////////////////////////////////

    I added classes to the display name and a div that contains the button, so feel free to style how you want to. Here is an image of the code that I recommend you remove and add to your current custom CSS style sheet. See image below:

    I apologize for the formatting of the code, our txt editor sometimes puts the indention of our code out of whack.

    Let me know how this works for you!

    Take Care,

    Ken - WPMU DEV Support

  • Ken Kimbrell

    Hello David-

    Could you please grant us temporary support access to your website so we can have a better look of your setup and settings? You can grant us access via WPMUDEV Dashboard plugin, there's no need to share credentials. Here's our detailed documentation page about it:
    https://premium.wpmudev.org/docs/getting-started/getting-support/#chapter-4

    We'll wait for your confirmation reply here, as we don't get any notification when a member is granting us support access. We could then dig in and further investigate this!

    Furthermore, can you please delete the custom css from the function, so I can look at how to style it on the front end and get you in the right direction?

    Take Care,

    Ken - WPMU DEV Support

  • David

    I tweaked your snippet, though, because the button shouldn't mail the current user. it should mail the user who is the author of the post:

    $display_name = get_the_author_meta('display_name');
    $current_user = get_the_author_meta('ID');

    If you go to any item under /marketplace/, you'll see the shortcode.

    And if you go to /inbox/, you'll also see message not sending. And the Ajax never returns user names when you type.

  • Ken Kimbrell

    Hello David,

    That works, it all depends on what you need the plugin to do. In the case you want a user to view a thread and see the Author's display name and be able to message the author then that will certainly work with some tweaks. You can have it say 'Message $author', above the button. It really all depends on what you want it to accomplish. Skies are the limit :slight_smile:

    I will look into it further!

    Take Care,

    Ken - WPMU DEV Support

  • Ken Kimbrell

    Hello David-

    I am getting an additional authentication that is required to gain access to your site.

    We can go with the alternate method of access...
    https://premium.wpmudev.org/contact/#i-have-a-different-question
    Please visit our private Contact page and complete the form with the following information:

    Subject: "Attn: Ken Kimbrell"

    In the Message box, please provide the following:

    - link back to this thread for reference
    - any other relevant urls

    - Admin login:
    Admin username
    Admin password
    Login url

    - Hosting Control Panel Login
    Admin username
    Admin password
    Login url

    - FTP credentials
    host
    username
    password
    (and port if required)
    ------

    In the meantime, I will be working on how to replicate the bug you are experiencing on my lab site.

    Take Care,

    Ken - WPMU DEV Support

  • Ken Kimbrell

    Hello David-

    After getting a better understanding of what you were trying to accomplish, I revised the code, see below:

    //////////////////////////////////
    // Adding custom shortcode
    /////////////////////////////////
    
    function custom_private_messaging(){
    
    $get_author_id  = get_the_author_meta('ID');
    $get_author = get_the_author_meta('display_name');
    $pmshortcode  = do_shortcode('[pm_user user_id="'. $get_author_id .'" subject=""]');
    $user  = is_user_logged_in();
      	if ($user){
    
    		echo    '<style>
    .ig-container .btn.disabled, .ig-container .btn[disabled],
    fieldset[disabled] .ig-container .btn {
    
    		 cursor: pointer;
    		 pointer-events: auto;
    
    }
    .align_pm_button,.pm_get_author_id{
    
    		text-align:center;
    
    }
    </style>';
    
    		echo 	'<div class="pm_get_author_id"> Message ' . $get_author . '! </div>';
    		echo 	'<div class="align_pm_button">' . $pmshortcode . '</div>';
    
    	}
    	else{
    
    		echo '<div style="text-align:center;" class="not_registered">You must be a registered member<br>
    		                                                               to send me private messages!
    		      </div>';
    	}
    }
    
    //Just add [pm_me] as a shortcode and get the current users dispaly name
    add_shortcode('pm_me', 'custom_private_messaging');
    
    //////////////////////////////////
    // Adding custom shortcode
    /////////////////////////////////

    As you can see, I did add a conditional that checks if the user is logged in then it can message authors, else it displays a message "You must be a registered member to send me private messages". That is just a little add on. I was successful in sending a message to a dummy post i made on a different account and able to read the message. Please try the following code and let me know how it works. Thanks!

    Take Care,

    Ken - WPMU DEV Support

  • Ken Kimbrell

    Hello David-

    There does seem to be a console error related to an ajax call. I noticed you have several plugins that use ajax, there could be some plugin conflict. I recommend you deactivating any plugins you are not currently using and see if the functionality returns. I have tested in both a local environment and on a live lab site and I can not replicate this issue :disappointed:

    Let me know how I can help!

    Take Care,

    Ken - WPMU DEV Support

  • Ken Kimbrell

    Hello David-

    When I go to your post and hit the call to action PM button. Once the form pops up I open up the console and hit send, then I get an ajax call error when trying to POST the message in google chrome dev tools. See image below:

    Let me know how I can help, I will continue to look into it for you. Do you think the tight security you have on the server is restricting the ajax call from being posted? Have you had problems with ajax calls in the past?

    Take Care,

    Ken - WPMU DEV Support

Thank NAME, for their help.

Let NAME know exactly why they deserved these points.

Gift a custom amount of points.