editting child theme

I have a freelancing site named bioinfexperts.com.
The site users are freelancers and clients. Clients post projects and freelancers bid on the projects (the usual known scenario).
Whenever I need to make changes on the childtheme, I do it first on another test site named genoexperts.com. Both sites have the same wordpress theme. So for every new change, I test it first on genoexperts and make sure its working correctly before I put it officially on bionfexperts.
So, I made some changes on the childtheme of genoexperts, which is to add a "Contact me" button in the profile of freelancers and in the project pages of clients. This button is linked to the private messaging plugin i got from your site.

The code to add such buttons is working greatly on genoexperts, but when I copied the code and put it in the childtheme of bioinfexperts, the "contact me" button does not appear, I do not know why.. If you can help me with this, I can provide you with login details for both sites.
Check the following images (ignore all styling differences between both sites, just pay attention to the contact me buttons)

This is how the freelancer profile looks like on bioinfexperts
https://www.dropbox.com/s/ttht8hy1glqjkyu/b1.png?dl=0

This is how it looks like on genoexperts
https://www.dropbox.com/s/oh4n9sdy6cz22q9/g1.png?dl=0

This is how the project page looks like on bioinfexperts
https://www.dropbox.com/s/b96361zivgzstzn/b2.png?dl=0

This is how it looks like on genoexperts
https://www.dropbox.com/s/gqg881in6ohfqjh/g2.png?dl=0

Many thanks in advance

  • Rupok
    • Support Ninja

    Hi Layal,

    Thanks for full details of your issue and screenshots. I'm clear about the issue. But not sure why this is happening. Can you please tell us how did you add that Contact Me button, I mean can you provide us the code which is generating that button on your child theme? Can you please also tell us on which child theme template file did you add that code? It will facilitate the troubleshooting process.

    It's really tough to say why this is not working on your live site without checking your site configuration and inspecting the elements live. I could tell you better about the issue if I could see it live, check your current configuration and make some tests on your sites. Would you mind allowing Support Access to both of those sites so we can have a closer look at this?

    To enable support access you can follow this guide here:
    http://premium.wpmudev.org/manuals/wpmu-dev-dashboard-enabling-staff-login/

    Please confirm here when you are done granting Support Access for both of those sites. I'm looking forward to hearing from you and resolving this issue as soon as possible.

    Have a nice day. Cheers!
    Rupok

  • Layal
    • Site Builder, Child of Zeus

    Thank you for your prompt reply !!
    Support granted.

    This is the code in the childtheme of genoexperts used to create the buttons

    functions.php
    add_action('author_contact_me','contact_me');
    function contact_me(){
    $author_id = get_query_var( 'author' );
    $author_name = get_the_author_meta('user_login', $author_id);
    //echo $author_name;
    ?>
    ?box=compose&to=<?php echo _e(get_the_author_meta('user_login', $author_id));?>" class="invite-freelancer btn-sumary contact-me-button">
    <?php _e("Contact me", ET_DOMAIN) ?>

    <?php }

    add_action('non_login_contact_me','nonlogin_contact_me');
    function nonlogin_contact_me(){
    ?>
    post_author ?>">
    <?php _e("Contact me", ET_DOMAIN) ?>

    <?php }

    add_action('product_page_contact_me','product_contact_me');
    function product_contact_me(){
    if ( !is_user_logged_in() ) {

    ?>
    post_author ?>">
    <?php _e("Contact me", ET_DOMAIN) ?>

    <?php }else{
    $author_id = get_query_var( 'author' );
    ?>
    ?box=compose&to=<?php echo _e(get_the_author_meta('user_login', $author_id));?>" class="btn btn-apply-project-item invite-freelancer btn-sumary contact-me-button">
    <?php _e("Contact me", ET_DOMAIN) ?>

    <?php }}

    and this is the code added to the css file of genoexperts

    #tab_inbox_details .ig-container .row{margin: 10px;}
    #tab_inbox_details .ig-container .mmessage-container{padding: 10px;}

    .btn-sumary.invite-freelancer.contact-me-button{padding-left: 10px;padding-right: 10px;margin-left: 12px;}

    .title-tab-profile h2 .login-btn{margin-left: 50px;}
    .title-tab-profile h2 .contact-me-button{margin-left: 50px !important;}
    .btn-fre-bid a {float: left;}
    .button-event li{float: left;padding: 0px;margin: 10px 6px 0 10px;}

    This code is already added to the child theme of bioinfexperts.

    If you have further questions, please ask me.

  • Adam Czajczyk
    • Support Gorilla

    Hello Layal!

    Thanks for granting access and sharing the code.

    I checked both sites (didn't make any changes there yet) and although I don't think there's anything wrong with your code I can see there are some differences between these sites. The bioinfoexperts site is running on WP 4.7 while the other one is still on a previous version, there are also different sets of plugins on both.

    I'm not sure how significant that is for the case but I think it may be related. Would you mind trying to update "genoexperts.com" to the most recent WP to see if the button stays there or if it gets removed?

    Could you also tell me please where these hooks come from (a theme or a plugin, if a plugin - which one?):

    - author_contact_me
    - non_login_contact_me
    - product_page_contact_me

    Best regards,
    Adam

  • Layal
    • Site Builder, Child of Zeus

    wordpress on genoexperts just updated, buttons still exist.

    - author_contact_me: this is related to the contact me button which appears in the freelancers profiles pages
    - non_login_contact_me: this is related to when a non-loged-in user presses on the contact me button
    - product_page_contact_me: this is related to the contact me button in the project pages.

    Those functions are associated with the private messaging plugin of wpmudev such that if a user presses on the contact me button, he should be navigated to his inbox page and the pop up of the compose message should open with the name of the person to be contacted present in the send-to field.

  • Adam Czajczyk
    • Support Gorilla

    Hello Layal!

    Thank you for your replay!

    I understand what these functions are supposed to do and I was asking about something a bit different. Let's stick to the first one "author_contact_me".

    by using

    add_action('author_contact_me', 'contact_me');

    line you are telling WordPress to execute your own "contact_me()" function when it encounters the "author_contact_me" hook somewhere else in the code - this may be a theme or one of the plugins. This hook must exists in order for your function to be executed. Since it's not any native WordPress hook, I was hoping that you could tell me what plugin does it come from. If the hook that you are using doesn't exist, the function doesn't get executed.

    I assumed that this is the issue because even despite that your code is present in "bioinfiexoerts" site child theme, it didn't seem to be executed.

    Therefore I just checked both your sites again and it looks like there are differences in parent theme code. I think the parent theme on "genoexperts" site must have been modified directly at some point in the past. For example, the "Author Template" (author.php file) is different in both cases.

    On "genoexperts" page there's this line in "author.php" file of parent theme:

    <?php do_action('author_contact_me');?>

    This is what I was referring to above. When this line is encountered in the file WordPress looks for any functions that are hooked to "author_contact_me" hook and it executes them. In this case, it executes your "contact_me()" function.

    There's no such line in the same template file on "bioinfoexperts" site though. As a result, your code is just not called.

    I didn't risk making any changes to the parent theme as using support access only I wouldn't be able to revert them in case anything went wrong and also, I do not know exactly what other changes has been made to a parent theme. I think you may want to review both parent themes and compare theme with original theme and it would most likely be best to "separate" all these custom changes into a child theme, then repeat them on both sites. Did you make all the changes by yourself or did you used some developer help also? I'm asking this because it may be a good idea to ask that developer (if you there was anyone involved of course) for a list of changes in parent theme or better yet, to move them to child theme.

    Kind regards,
    Adam

  • Layal
    • Site Builder, Child of Zeus

    you are right, that piece of code in the author.php was what its all about (a previous developer has done this). If I add this code to author.php in bioinfexperts.com, the contact me button appears. So thanks a lot!

    I have another question, I want that when a user presses on this button, the user gets navigated to the inbox page and the compose box appears having the name of the person to be contacted appearing in the send to field. This was working in genoexperts where the url that the page gets navigated to is:
    ?box=compose&to=<?php echo _e(get_the_author_meta('user_login', $author_id));?>" class="invite-freelancer btn-sumary contact-me-button">

    For bioinfexperts, i have used : " class="invite-freelancer btn-sumary contact-me-button">
    Whats happens is that the user gets navigated to the inbox page, but the compose box does not open. Do you know why ?

  • Dimitris
    • Support Star

    Hey there Layal,

    hope you're doing good and don't mind me chiming in here! :slight_smile:

    As the live website has a number of plugins which aren't available in testing site and just in case there's a conflict somewhere, could you please try to install them in test site too?

    If the issue can be recreated there, you could then perform a test as described in a nice flow chart here https://premium.wpmudev.org/manuals/using-wpmu-dev/getting-support/
    (just scroll down a bit to see the image)

    In general, try to duplicate your live site in test site so you could better inspect its behaviour.

    Warm regards,
    Dimitris

  • Layal
    • Site Builder, Child of Zeus

    Here is what i did :
    - genoexperts : all missing plugins are installed, still the compose box appears perfectly
    - I followed the workflow, and still I cannot get the compose box to appear on bioinfexperts
    - tried deactivating all plugins on bioinfexperts, still the compose box does not appear

    Therefore, the problem still unfortunately persists

  • Adam Czajczyk
    • Support Gorilla

    Hello Loyal!

    I checked both your sites one more time and it's again an issue of the child-theme of "bioinfoexperts" site.

    Inside the "functions.php" file of a child theme of "genoexperts" site there's this code:

    function inbox_tab_open() {
       	if($_GET['box'] =='inbox' || $_GET['box'] =='unread' || $_GET['box'] =='read' || $_GET['box'] =='sent' || $_GET['box'] =='archive' || $_GET['box'] =='setting'){?>
    	<script type="text/javascript">
         jQuery(function(){
         	jQuery('#myTab li:last-child').addClass("active");
         	jQuery('#tab_inbox_details').addClass("active in");
         	jQuery('#tab_inbox_details').removeClass("fade");
         	jQuery('#tab_account_details').removeClass("fade active");
         	jQuery('#myTab li:first-child').removeClass("active");
        })
         </script>
         <?php }
    }
    add_action( 'wp_footer', 'inbox_tab_open' );

    What it does it that it "listens" to the URL attributes and if there's a "?box=compose" variable passed to the page it triggers the message "compose" box with jQuery.

    There's no such code on your "bioinfoexperts" page and that's why this doesn't work. Please put it into the "functions.php" file of a child-theme on "bioinfoexperts", make sure that you cleared all the caches and it should work then.

    Let me know if it helped, please!

    Best regards,
    Adam

  • Layal
    • Site Builder, Child of Zeus

    just to clear another thing.. I removed all the code in functions.php of genoexperts. when i type the url
    http://www.genoexperts.com/inbox/?box=compose
    I get the compose box
    why this is not happening in bioinfexperts?
    I deactivated all plugins in bioinfexperts, also i tried deleting everything in the childtheme of bioinfexpers, and still this compose box is not appearing when i enter the url
    http://www.bioinfexperts.com/inbox/?box=compose

  • Adam Czajczyk
    • Support Gorilla

    Hello Layal!

    I tried to check your sites again and while I was able to check "bioinfoexperts" I wasn't able to access or even load "genoexperts". Are you making any changes to it?

    Could you please make sure that the "genoexperts" works as it did before and that support access is granted and also put the code that I suggested recently again to the "functions.php" file of child theme in "bioinfoexperts" site so I could check it WITH this code present there?

    I'm eager to help you make it work but since it's quite a specific setup I need to work with you step by step so I would really appreciate that :slight_smile:

    Best regards,
    Adam

  • Layal
    • Site Builder, Child of Zeus

    I dunno why you were not able to access genoexperts, yes i was modifying it but it was accessible . Anyway, I returned everything as it was before and added the code in bioinfexperts.
    I just want to point out to the purpose of the code that you pointed out to, it is explained in this other post:
    https://premium.wpmudev.org/forums/topic/make-private-messaging-inbox-page-appear-under-a-tab#post-1186607
    Also i want to make it clear (to make things easier for you) that private messaging in genoeperts is in the profile page, while in bioinfexperts, its in the inbox page.
    I hope you can manage to solve this issue.

  • Dimitris
    • Support Star

    Hey there Layal,

    I trust you're doing good today! :slight_smile:

    Could you please re-grant us access to genoexperts.com as it seems that expired (I get a plain white screen). You can do so via WPMUDEV Dashboard plugin as described here
    https://premium.wpmudev.org/manuals/wpmu-dev-dashboard-enabling-staff-login/

    Also i want to make it clear (to make things easier for you) that private messaging in genoeperts is in the profile page, while in bioinfexperts, its in the inbox page.
    I hope you can manage to solve this issue.

    It should be the "if" conditional of your jQuery script that doesn't match the /profile/ page.
    Could you please try to replace
    if($_GET['box'] =='inbox' || $_GET['box'] =='unread' || $_GET['box'] =='read' || $_GET['box'] =='sent' || $_GET['box'] =='archive' || $_GET['box'] =='setting'){?>
    with
    if($_GET['box'] =='profile' || $_GET['box'] =='inbox' || $_GET['box'] =='unread' || $_GET['box'] =='read' || $_GET['box'] =='sent' || $_GET['box'] =='archive' || $_GET['box'] =='setting'){?>
    and test if that makes any difference?

    Warm regards,
    Dimitris

  • Layal
    • Site Builder, Child of Zeus

    1- I dunno whats happening in genoexperts, everytime i press on grant access, i get a white page. I tried logging in and out , still same problem

    2- why should replace inbox with profile? the inbox page for private messaging on bioinfexperts is names 'inbox' and not profile (it is named profile on genoexperts). Anyway, I tried it and it didnt work

    3- Can we ignore genoexperts for the moment? and Can u tell me what link should I use on bioinfexperts that will open the compose box for me ?
    Regarding genoexperts, as I have mentioned before, all the code in the childtheme has nothing to do with opening the compose box, because, when I empty the childtheme, nothing changes, the compose box still opens.

  • Dimitris
    • Support Star

    Hello Layal

    That was my mistake, I messed up the URLs. I can see that we should fix this https://bioinfexperts.com/inbox/?box=compose as the previous version of this page you shared (http://www.bioinfexperts.com/inbox/?box=compose) doesn't seem to resolve.

    I made some more tests and I think that next snippet will do the trick for you, simply insert it inside functions.php of your child theme and let me know how that goes.

    function inbox_tab_open_compose() {
    	if($_GET['box'] =='compose'){
    ?>
    	<script type="text/javascript">
        	  jQuery(function(){
    	    jQuery('.mm-compose').trigger("click");
        	  })
            </script>
    <?php
    	}
    }
    add_action( 'wp_footer', 'inbox_tab_open_compose' );

    Warm regards,
    Dimitris

  • Layal
    • Site Builder, Child of Zeus

    one last question regarding your code:

    function inbox_tab_open_compose() {
    	if($_GET['box'] =='compose'){
    ?>
    	<script type="text/javascript">
        	  jQuery(function(){
    	    jQuery('.mm-compose').trigger("click");
        	  })
            </script>
    <?php
    	}
    }
    add_action( 'wp_footer', 'inbox_tab_open_compose' );
    '

    I also want to pass the 'to' field in the url such that the url looks like:

    http://www.bioinfexperts.com/inbox/?box=compose&to=personName

    so when the compose box opens, the 'send to' field will carry the name of personName
    How should I edit your code to get this working?

    loads of thanks :slight_smile:

  • Dimitris
    • Support Star

    Hello Layal and happy new year! :slight_smile:

    As the "send_to" input field is using a auto-complete functionality with username and First Last names, this isn't that simple to implement like previous trigger action.
    I already pinged a colleague dev to shed some light here, just in case this is something easy to implement and doesn't require any extend custom development.
    I'll let you know as soon as I've got some valuable feedback.

    Take care,
    Dimitris

  • Dimitris
    • Support Star

    Hey there Layal,

    could you please try to make a change in
    /wp-content/plugins/private-messaging/app/views/shortcode/_compose_form.php

    First download the file locally and keep it safe for backup.
    Then edit the file in server, at the very bottom you'll see a script from line 92 to line 120.
    Simply replace it with next snippet.

    <script type="text/javascript">
            jQuery(document).ready(function ($) {
                var options=[];
                var items =[];
                <?php
                if ( ( $uname = mmg()->get( 'to', false ) ) !== false ) {
                    $user = get_user_by( 'login', $uname );
                    if ( is_object( $user ) && $user->ID != get_current_user_id() ) {
                        ?>
                            var options = [{
                                id:'<?php echo $user->ID ?>',
                                name:'<?php echo $user->user_login ?>'
                            }];
                            var items=['<?php echo $user->ID ?>'];
                        <?php
                    }
    
                }
                ?>
                window.mm_compose_select = $('#mm_message_model-send_to').selectize({
                    valueField: 'id',
                    labelField: 'name',
                    searchField: 'name',
                    options: options,
                    create: false,
                    items:items,
                    load: function (query, callback) {
                        if (!query.length) return callback();
                        var instance = window.mm_compose_select[0].selectize;
                        $.ajax({
                            type: 'POST',
                            url: '<?php echo admin_url( 'admin-ajax.php?action=mm_suggest_users&_wpnonce=' . wp_create_nonce( 'mm_suggest_users' ) ) ?>',
                            data: {
                                'query': query
                            },
                            beforeSend: function () {
                                instance.$control.append('<i style="position: absolute;right: 10px;" class="fa fa-circle-o-notch fa-spin"></i>');
                            },
                            success: function (data) {
                                instance.$control.find('i').remove();
                                callback(data);
                            }
                        });
                    }
                });
    
            })
        </script>

    Let me know how that goes!
    Take care,
    Dimitris

  • Layal
    • Site Builder, Child of Zeus

    Ok now I REALLY regret not taking advantage of the black Friday offer :slight_smile: !!
    It worked perfectly, thanks a lot !! ... This functionality was needed so much in my site.

    A small issue that I noticed:
    after the compose box opens having the recipient name inside the sendto box, if I write a message and then press on the send button, the message gets sent perfectly, and the compose box disappears, but afterwards it reopens directly again (it should not) like what you can see in this image:

    https://www.dropbox.com/s/gdo0zx6gvpo2wad/reopens.png?dl=0

    Is this something that can be solved in a straight forward way?

  • Dimitris
    • Support Star

    Hey there Layal,

    hope you're doing good today! :slight_smile:

    This is happening because after successfully sending a message, the page refreshes then the script I shared previously to pop-up the compose message window triggers again.
    I already asked lead dev of this plugin to let me know if we surpass this somehow, I'll let you know as soon as possible.

    Take care,
    Dimitris

  • Dimitris
    • Support Star

    Hey there Layal,

    I trust you're doing good today!

    I wasn't able to get any additional information from plugin's lead developer, I already pinged him again so I will keep you posted on this as soon as possible! :slight_smile:
    Your patience here is highly appreciated as our dev team is constantly working on new tasks and different members' issues.

    Warm regards,
    Dimitris

  • Dimitris
    • Support Star

    Hey there Layal,

    hope you're doing good!

    I'm really sorry for the delay here, I pinged again our dev about this so I should have some feedback pretty soon. It seems that this had been lowered down in their cues as they constantly address multiple issues. Your patience is highly appreciated here! :slight_smile:

    Warm regards,
    Dimitris

Thank NAME, for their help.

Let NAME know exactly why they deserved these points.

Gift a custom amount of points.