- This topic has 5 replies, 3 voices, and was last updated 6 years, 2 months ago by
Joanne Smith.
-
AuthorPosts
-
September 20, 2017 at 5:33 am #388662
Joanne Smith
I have been asked if I can have the site LOGO change depending on the USER logged in
I came across this code for the login on a forum — how would I do something like this on your theme ??
my potential client wants to set up a ecommerce website for different clients of his and then when they login to the site they will see
1) ONLY selected product categories he has given permission for them to see from his products uploaded ((( I found another plugin for this ))
2) AND more importantly the site would be branded to their own business logo and LOOK like their own mini site for their staff!!so instead of developing multiple sites — he wants everything under 1 site
here is the code below — (( surly this is possible ))
add_filter(‘avf_logo_final_output’, ‘avf_logged_logo_final_output’);
function avf_logged_logo_final_output($logo) {
$headline_type = “h1”;
if($dimension === true) $dimension = “height=’100′ width=’300′”; //basically just for better page speed ranking 😛
$loggedinlogo = ““;
$loggedoutlogo = ““;
if ( is_user_logged_in() ) {
$logo = “<$headline_type class=’logo bg-logo’>“.$loggedinlogo.”$sub</$headline_type>”;
} else {
$logo = “<$headline_type class=’logo bg-logo’>“.$loggedoutlogo.”$sub</$headline_type>”;
}return $logo;
}and then a development of the code for the site
Hi!
Yes, use Ismaels code but replace:
if ( is_user_logged_in() ) {
$logo = “<$headline_type class=’logo bg-logo’>“.$loggedinlogo.”$sub</$headline_type>”;
} else {
$logo = “<$headline_type class=’logo bg-logo’>“.$loggedoutlogo.”$sub</$headline_type>”;
}with
if ( is_user_logged_in() || is_page(array(20)) ) {
$logo = “<$headline_type class=’logo bg-logo’>“.$loggedinlogo.”$sub</$headline_type>”;
} else {
$logo = “<$headline_type class=’logo bg-logo’>“.$loggedoutlogo.”$sub</$headline_type>”;
}instead of 20 insert the id of the page where you want to show the “logged in” logo. You can even insert several ids – just separate the with commas like 20,30,70.
September 20, 2017 at 8:18 am #388827Leo
StaffCustomer SupportHi there,
Looks like you should be able to similar method but with this hook: https://docs.generatepress.com/article/generate_logo_output/
September 20, 2017 at 8:30 am #388835Tom
Lead DeveloperLead DeveloperThis filter might work better: https://docs.generatepress.com/article/generate_logo/
Something like this:
add_filter( 'generate_logo', 'tu_logged_in_logo' ); function tu_logged_in_logo( $logo ) { if ( is_user_logged_in() ) { return 'URL TO YOUR LOGGED IN LOGO'; } // Otherwise, return our default logo return $logo; }
September 20, 2017 at 5:39 pm #389092Joanne Smith
that just turned OFF the logo
I had a quick hunt around last night and could not find anything suitable — Maybe I am BARKING up the wrong TREE but if a potential customer asks for it I will look for a solution — mind you it is a weird request! — (( you always get something out of left field )
so here goes again –I will be using this plugin to create a wholesale woo-commerce site where he cane assign products to each unique registered user on the site.
https://barn2.co.uk/woocommerce-wholesale-customer-categories/
BUT the client wants a ‘upload image button’ on the wordpress users dashboard so he can load their company logo –to brand the wholesale experience to 1 customer who is logged in at that time — can you replace the LOGO at the top of he live page with their LOGO so it looks like their site ?
otherwise the only way around it would be to create a sub-domain on the server for each new client of his and set up a woo store on each sub domain and upload the products he just wants for those clients — but that is a CRAZY way to do it as well — using up so much space on the hosting and time consuming!
????
Joanne
September 20, 2017 at 8:31 pm #389144Tom
Lead DeveloperLead DeveloperSomething like that gets quite complex.
First, you need to add the option to the user profile.
Then you’d need to use the filter above (it works, I promise), and call the option using this function: https://codex.wordpress.org/Function_Reference/get_user_meta
So, super quick and likely needs tweaking:
add_filter( 'generate_logo', 'tu_logged_in_logo' ); function tu_logged_in_logo( $logo ) { $user_logo = get_user_meta( $user_id, 'your_option_name', true ); if ( $user_logo ) { $logo = $user_logo; } return $logo; }
You’ll need to figure out the $user_id variable, and the $user_logo variable will need to return a URL set in the user options.
September 21, 2017 at 6:44 am #389386Joanne Smith
Thanks —
I will give it a TRY!!Joanne
-
AuthorPosts
- You must be logged in to reply to this topic.