Tahtsin värskendada WordPressi saiti ja lisada iga postituse alla jaotise Autori kohta. See oli veidi karmim, kui ma arvasin - ja tegelikult vajab see veelgi rohkem programmeerimist, kuid siin on esimene lõik:
Autor: Veebisait: Teave:
Järgmisena kontrollin, kas keegi on tegelikult sisse logitud, ja kuvan lingi Muuda profiili, et inimene saaks lihtsalt oma teavet klõpsata ja värskendada (värskendasin seda postitust ... Ajay suurepärane kommentaar ja küsimus!):
">Muuda profiili
Lisasin klass = ”autor” stiililehele, et see ka kena välja näeks.
Soovin koodi puhastada, et aadressi või teavet ei kuvata, kui seda pole; arvan siiski, et pean selle jaoks andmebaasi tegelikud päringud skriptima. Pange tähele linki „Redigeeri profiili” ... selle ümbritseb if-lause, mis kuvab seda ainult siis, kui kasutaja on sisse logitud. Ma arvasin, et see oli kuidagi lahe, nii et tahtsin seda teiega jagada, juhul kui soovite seda kasutada!
if (‘â?? != $user_ID) {
What is the purpose of this?
Hi Ajay!
I don’t want to show the Edit Profile link unless someone is actually logged in. So the function get_currentuserinfo() will bring back user information and the if statement verifies if the current user has a user_id… it’s a means of checking whether or not they are logged in.
In other words – if you are logged in, you see a link to edit profile. If you are not, you don’t see that link.
Doug
Before the get_currentuserinfo you should declare ‘global $user_ID;’ otherwise it doesn’t work.
Thanks, Martijn!
Nice Doug! I’ll have to implement that with version 1.0 when I add the options. Thanks for the tip.
Tere Doug,
just wondering do you know how i could use this depending on the user who is logged in?
So if the user logged in was JohnSmith it would display ‘A’ and if the user logged in was BillBob it would display ‘B’ ?
Aitäh!
Tere Mike,
I’m pretty sure that the variable $user_id will return the actual User ID within your Users section in admin. So you might be able to build a case statement of if logic….
if ($user_id=="1") { echo "Doug"; }
I’ve not tested this but I’m pretty sure you have to put it within the context of the get_currentuserinfo function.
Doug
You could even tie it to the $user_level. Checkout the WordPress codex.
Nice catch Martijn!
Hi Doug. Thanks for sharing. Unfortunately, this code did not work for me:
Thanks! Works perfectly.