Karkom Posted January 2, 2021 Posted January 2, 2021 Site URL: https://www.ghoulsmagazine.com Hello all, my Website has a Members Area. When a registered members is logged in, i'd like the website Logo to redirect the user to the Members Home Page rather than the regular site Home Page. Is this possible and if so, I can this be set up please? Thanks for your help
tuanphan Posted January 5, 2021 Posted January 5, 2021 Hi. Can you provide a test account? We can check easier Email me if you have need any help (free, of course.). Answer within 24 hours. Or send to forum message Contact Customer Care - Learn CSS - Buy me a coffee (thank you!)
Karkom Posted January 11, 2021 Author Posted January 11, 2021 Hi @tuanphan Acc: kairosss@hotmail.com pswrd: test12345678 thanks!
tuanphan Posted January 13, 2021 Posted January 13, 2021 @creedon Do you think this is possible/not? Thank you. Just checked body tag when logged in, no special class to target. Email me if you have need any help (free, of course.). Answer within 24 hours. Or send to forum message Contact Customer Care - Learn CSS - Buy me a coffee (thank you!)
creedon Posted January 13, 2021 Posted January 13, 2021 @tuanphan It is possible with a little Javascript. Find my contributions useful? Please like, upvote, mark my answer as the best ( solution ), and see my profile. Thanks for your support! I am a Squarespace ( and other technological things ) consultant open for new projects.
creedon Posted January 13, 2021 Posted January 13, 2021 Add the following to Settings > Advanced > Code Injection > FOOTER. Do not use the following code. Find the other, better version of the code elsewhere in this thread. <script> $( ( ) => { // when member is logged in change url of logo const url = '/home-1'; // do not change anything below, there be the borg here if ( ! $( '.user-accounts-link .auth' ).length ) return; $( '.header-title a' ).attr ( 'href', url ); } ); </script> This is for a v7.1 site. For others following along Karkon already has jQuery installed. If you don't then add the following to Settings > Advanced > Code Injection > HEADER. <script src="https://ajax.googleapis.com/ajax/libs/jquery/3.5.1/jquery.min.js"></script> Let us know how it goes. Find my contributions useful? Please like, upvote, mark my answer as the best ( solution ), and see my profile. Thanks for your support! I am a Squarespace ( and other technological things ) consultant open for new projects.
Karkom Posted January 16, 2021 Author Posted January 16, 2021 Hi @creedon thanks so much for your advise. I copied the below code in the footer. Quote <script> $( ( ) => { // when member is logged in change url of logo const url = '/home-1'; // do not change anything below, there be the borg here if ( ! $( '.user-accounts-link .auth' ).length ) return; $( '.header-title a' ).attr ( 'href', url ); } ); </script> it does re-direct the logo to the members home page /home-1 but it looks like it also works when members aren't logged in. I just tried while logged out and it takes me to the access denied page all the time. Any other suggestion? thanks
creedon Posted January 17, 2021 Posted January 17, 2021 14 hours ago, Karkom said: Any other suggestion? It appears the issue is a bit deeper than my initial testing indicated. 😞 I suggest backing out the code I posted and let me cogitate on the issue. The code being in place was invaluable to further testing how member authentication is functioning as far as the elements on the page go. Just a quick note for those into the deeper stuff. When the page is first loaded both the auth and noauth class elements are loaded. Then some code comes along and removes the unneeded element depending on if the member is logged in or not. The jQuery ready document code I wrote runs before the member is/is not logged in code runs. So it always finds the auth class. Of course when I was developing the code I was either logged in or not logged in and the code I ran in the console happened way after jQuery's document ready and the member logged in or not code ran. I'm thinking Mutation Observer! One of my favorite friends for those ephemeral elements! 🙂 LOL! Find my contributions useful? Please like, upvote, mark my answer as the best ( solution ), and see my profile. Thanks for your support! I am a Squarespace ( and other technological things ) consultant open for new projects.
Karkom Posted January 17, 2021 Author Posted January 17, 2021 Thanks for the quick feedback and for looking into this issue @creedon Really appreciated!
Karkom Posted January 20, 2021 Author Posted January 20, 2021 Hi @creedon I was wandering if you had a chance to think about this issue a bit more? thanks 🙂
creedon Posted January 22, 2021 Posted January 22, 2021 Add the following to Settings > Advanced > Code Injection > FOOTER. <script> $( ( ) => { /* change url of logo when member is logged in to site SS Version : 7.1 */ const url = '/home-1'; // do not change anything below, there be the borg here if ( ! ( 'MutationObserver' in window ) ) return; const observer = new MutationObserver ( function ( mutations ) { mutations.forEach ( function ( mutation ) { if ( ! mutation.removedNodes.length ) return; observer.disconnect ( ); let $e = $( mutation.removedNodes [ 0 ] ); if ( $e.hasClass ( 'auth' ) ) return; $( '.header-title a' ).attr ( 'href', url ); } ); } ); // start listening for changes in element with class user-accounts-text-link observer.observe ( $( '.user-accounts-text-link' ) [ 0 ], { childList: true } ); } ); </script> Normally I would have updated my original code post but in this case I think there is an instructive element to the process. I've done the best I can in testing as on my test site I don't have full access to member areas functionality. SS please consider allowing full access to member areas on non-published sites, like many of your other features that are considered premium. Help the developers to help you. Not that I expect SS to read this but if you do, there you go. As long as the new code is not causing any problems, please leave it in place so I can examine it, if it doesn't work. Let us know how it goes. Find my contributions useful? Please like, upvote, mark my answer as the best ( solution ), and see my profile. Thanks for your support! I am a Squarespace ( and other technological things ) consultant open for new projects.
Karkom Posted January 22, 2021 Author Posted January 22, 2021 Hi @creedon I tried with this code and so far so good.. it really seems to be working. Thank you so much man, honestly!!
creedon Posted January 22, 2021 Posted January 22, 2021 1 hour ago, Karkom said: it really seems to be working. Thank you so much man, honestly!! That is good news! You are welcome. Find my contributions useful? Please like, upvote, mark my answer as the best ( solution ), and see my profile. Thanks for your support! I am a Squarespace ( and other technological things ) consultant open for new projects.
Recommended Posts
Archived
This topic is now archived and is closed to further replies.