Need a little help with JS

I want to replace the <select> field for the "Organizer" field under the "Organizer Details" section with a disabled text field that should say show the display name of the current logged in user. Please help.

  • Nahid
    • Tech Support

    Hey TheQureshi !
    Hope you are having a great day!

    Nahid here, following up from our last Live Chat session. Could you please try replacing the code in the previously added mu-plugin with the following mentioned code?

    <?php
    add_action( 'wp_head', 'custom_js_snippet' );
    function custom_js_snippet() {
    	$current_user = wp_get_current_user();
    	?>
    		<script type="text/javascript">
    			(function($) {
    				$(document).ready(function() {
    					$('.postid-291 #tribe-events form #event_tribe_organizer .tribe-section-content tbody tr:first-child td:nth-of-type(2) #s2id_saved_tribe_organizer').replaceWith(
    							'<input type="text" value="<?php echo $current_user->display_name ?>" disabled>'
    						);
    				});
    			})(jQuery);
    		</script>
    	<?php
    }

    Hope this helps. Let us know if this works for you. Thanks!

    Kind regards,
    Nahid

  • Nahid
    • Tech Support

    Hey TheQureshi !
    Hope you are doing well today!

    I'm sorry to hear that the above code didn't work for you, which it did as expected on my test site. The FTP credentials that you had shared during our chat session didn't work for me due to an authentication error. Could you resend working FTP and WordPress admin credentials to us so that we can test the code directly in the mu-plugin and make required changes in it? You can send that privately through our secure contact form: https://premium.wpmudev.org/contact/#i-have-a-different-question

    Send in:

    Subject: "Attn: Nahid Mohit"
    -WordPress admin username
    -WordPress admin password
    -login url
    -FTP credentials (host/username/password)
    -link back to this thread for reference
    -any other relevant urls

    We'll be looking forward to hearing back from you. Thanks!

    Kind regards,
    Nahid

      • Nahid
        • Tech Support

        Hey TheQureshi !
        Hope you are doing well today!

        Thank you for sending the credentials out. Unfortunately, the newly sent credentials didn't work as well for me and my colleagues. It outputs the following message in the FTP client:

        Response:    530 Login authentication failed
        Error:    Critical error: Could not connect to server

        It seems the credentials are either not correct or not working for some reason. Could you try sending the credentials of the default FTP user temporarily or create a new one and send it's credentials verifying that it works on your end?

        Looking forward to hearing back from you. Thanks!

        Kind regards,
        Nahid

        • Qureshi
          • Flash Drive

          Hi Nahid,

          Very strange!

          Since the credentials are working fine on my end. I am using FileZilla on MacOS and it's opening fine without any errors.

          Anyways, please use the plugin "File Manager" in WordPress to update the code.

          I hope this won't take more time.

          Thanks,
          Qureshi

  • Nahid
    • Tech Support

    Hey TheQureshi !
    Hope you are having a great day!

    I changed the mu-plugin code using the File Manager plugin to the following:

    <?php
    add_action( 'wp_head', 'custom_js_snippet' );
    function custom_js_snippet() {
    	$current_user = wp_get_current_user();
    	?>
    		<style type="text/css">
    			.postid-291 #tribe-events form #event_tribe_organizer .tribe-section-content tbody tr:first-child td:nth-of-type(2) #s2id_saved_tribe_organizer {display: none;}
    		</style>
    		<script type="text/javascript">
    			(function($) {
    				$(document).ready(function() {
    					$('.postid-291 #tribe-events form #event_tribe_organizer table > tbody > tr > td:nth-of-type(2)').append(
    							'<input type="text" value="<?php echo $current_user->display_name ?>" disabled>'
    						);
    				});
    			})(jQuery);
    		</script>
    	<?php
    }

    The code seems to be working as expected now. Here's a screenshot for reference:

    Hope this helps. Let us know if you need any further assistance regarding this. Thanks!

    Kind regards,
    Nahid

  • Nahid
    • Tech Support

    Hey TheQureshi !
    Hope you are doing well today!

    I have added the following Custom CSS using the Simple Custom CSS and JS plugin in order to remove the "Add Another Organizer" button:

    .postid-291 #tribe-events form #event_tribe_organizer table.tribe-section-content > tfoot {
        display: none;
    }

    Here's a screenshot for reference:

    Hope this helps. Let us know if you need any further help regarding this. Thanks!

    Kind regards,
    Nahid

Thank NAME, for their help.

Let NAME know exactly why they deserved these points.

Gift a custom amount of points.