Change prosites url during registration

I'm using prosites and when a user generates a new blog they are given a link that directs them to the backend. I would like to change that link to direct them to the blog itself. I found this article.
https://premium.wpmudev.org/forums/topic/pro-site-change-wp-admin-url

I would like to know if there is any function without edit the plugin core file.

  • Dimitris

    Hello there Audrey,

    hope you're doing good today! :slight_smile:

    Our SLS team provided another approach via JS, which doesn't require to edit any Pro Sites files.
    Please do create a new MU-plugin file like: wp-content/mu-plugins/prosites-redirect.php (just create the /mu-plugins/ folder, if it doesn't exist already) and in there and the exact snippet:

    <?php
    add_action( 'wp_footer', function(){
    
    global $psts;
    
    if ( ! is_page() || get_the_ID() != $psts->get_setting( 'checkout_page' ) || ! isset( $_REQUEST['activation'] ) ) {
        return;
    }
    
    ?>
    <script type="text/javascript">
        (function($){
            $(document).ready(function(){
    
                var blog_link = $('#psts-payment-info-received p:eq(2) a'),
                    admin_url = blog_link.attr( 'href' ),
                    blog_url;
    
                if (typeof blog_link == 'undefined') {
                    return;
                }
    
                blog_url = admin_url.split( 'wp-admin' )[0];
                blog_link.attr( 'href', blog_url ).text( blog_url );
            });
        })(jQuery);
    </script>
    <?php
    
    } );

    Warm regards,
    Dimitris

  • Konstantinos Xenos

    Hi Audrey ,

    Could you provide access to your installation so I can take a look on your settings and adjust the code as needed? There are different settings that basically alter the confirmation pages so there might be an issue due to differences.

    I also need 1 clarification from you if possible:
    A screenshot to point out which link exactly you want to have changed as there are different links & ways for a login to happen via Pro Sites, so I can change the one needed.

    You can send me the information needed to make the changes for you privately through our contact form: https://premium.wpmudev.org/contact/#i-have-a-different-question by following this example:

    Subject: "Attn: Konstantinos Xenos"
    
    - Admin login ( if Multisite please provide Super Admin details ):
    Admin Username:
    Admin Password:
    Login URL: 
    
    - FTP credentials
    Hostname:
    Username:
    Password:
    Port:
    Key-File ( and password ) if needed
    
    - Link back to this thread for reference
    - Any other relevant URLs -or- information regarding the issue that was not included in this thread

    Regards,
    Konstantinos

  • Konstantinos Xenos

    Hey Audrey !

    I see that you're using both PayPal & Stripe. I've already updated the mu-plugin code on your site so there's no need for you to change anything and the text should now look something like this ( this is from my dev environment ):

    ---

    Since you're not using Sandbox for your site I didn't make an actual test on your end though, so could you be kind and do 1 more test to see if everything is as you want ?

    New code snippet for future reference:

    <?php
    
    add_action( 'wp_footer', 'change_ps_url_after_registration' );
    function change_ps_url_after_registration() {
    	global $psts;
    
    	if ( ! is_page() || get_the_ID() != $psts->get_setting( 'checkout_page' ) || ( ! isset( $_REQUEST['activation'] ) && 'complete' != $_REQUEST['action'] ) ) {
    		return;
    	}
    	?>
    	<script type="text/javascript">
    		( function( $ ) {
    			$( document ).ready( function() {
    				var blog_text = $( '#psts-payment-info-received p' ),
    					blog_link = $( '#psts-payment-info-received p a[href*="wp-admin"]' ),
    					admin_url = blog_link.attr( 'href' ),
    					blog_url;
    
    				if ( typeof blog_link == 'undefined' ) {
    					return;
    				}
    
    				blog_url = admin_url.split( 'wp-admin' )[0];
    				blog_link.attr( 'href', blog_url ).text( blog_url );
    				blog_text.contents().filter( function() {
    					return this.nodeType == 3
    				} ).each( function() {
    					this.textContent = this.textContent.replace( 'Admin ','' );
    				} );
    			} );
    		} )( jQuery );
    	</script>
    	<?php
    }

    Regards,
    Konstantinos

Thank NAME, for their help.

Let NAME know exactly why they deserved these points.

Gift a custom amount of points.