Fügen Sie den Logout-Button im Admin-Menü hinzu

Ich möchte eine Logout-Schaltfläche im Seiten-Admin-Menü hinzufügen (weil ich die Admin-Leiste für die Benutzer deaktiviere). Also dachte ich, add_menu_page () ist die Art, es zu tun, aber wie man den Link zu der betrachteten function hinzufügt?

Hier ist was ich getan habe:

add_action( 'admin_menu', 'my_logout_menu' ); function my_logout_menu() { add_menu_page( 'Logout', 'Logout', 'read', 'logout', 'my_logout' );} function my_logout() { echo wp_logout_url( $redirect );}//here is I don't know what to do. 

Benutze ich den richtigen Ansatz? Oder gibt es andere einfachere Möglichkeiten?

Solutions Collecting From Web of "Fügen Sie den Logout-Button im Admin-Menü hinzu"

Ich benutze dies als eine benutzerdefinierte Logout-Taste, es zeigt auch ein zufälliges Zitat vor dem Abmelden des Benutzers. Ich denke, Sie können es an Ihre Bedürfnisse anpassen, indem Sie das entfernen, was Sie nicht brauchen.

Anleitung: Kopieren Sie den Code unten und speichern Sie als Benutzer-logout.php Erstellen Sie einen Ordner namens Benutzer-Logout, laden Sie die Datei und die Bilder unten, um zu arbeiten.

Irgendwelche Probleme lassen Sie mich einfach wissen

Bilder: Bildbeschreibung hier eingebenBildbeschreibung hier eingebenBildbeschreibung hier eingeben

Code:

  < ?php /* Plugin Name: Users Logout Button Plugin URI: http://www.exe.ie Description: Logout menu button for users Author: Daniel Conde Author URI: http://www.exe.ie */ function users_add_login_logout_link() { $quotes = array( "Commitment leads to action. Action brings your dream closer. 

Marcia Wieder", "Change will not come if we wait for some other person or some other time. We are the ones we've been waiting for. We are the change that we seek. Barack Obama ", "Nothing can stop the man with the right mental attitude from achieving his goal; nothing on earth can help the man with the wrong mental attitude. Thomas Jefferson", "Man, alone, has the power to transform his thoughts into physical reality; man, alone, can dream and make his dreams come true. Napoleon Hill ", "Try not to become a man of success but a man of value. Albert Einstein", "People who don't take risks generally make about two big mistakes a year. People who do take risks generally make about two big mistakes a year. Peter Drucker ", "Cherish your visions and your dreams as they are the children of your soul, the blueprints of your ultimate achievements. Napoleon Hill ", "I am careful not to confuse excellence with perfection. Excellence, I can reach for; perfection is God's business. Michael J. Fox", "Old friends pass away, new friends appear. It is just like the days. An old day passes, a new day arrives. The important thing is to make it meaningful: a meaningful friend - or a meaningful day. Dalai Lama ", "When I let go of what I am, I become what I might be Lao Tzu ", "An eye for an eye only ends up making the whole world blind. Mohandas Gandhi ", "Every artist was first an amateur. Ralph Waldo Emerson", "People often say that this or that person has not yet found himself. But the self is not something one finds, it is something one creates. Thomas S. Szasz ", "Unless you try to do something beyond what you have already mastered, you will never grow. Ralph Waldo Emerson ", "There are no such things as limits to growth, because there are no limits to the human capacity for intelligence, imagination, and wonder Ronald Reagan ", "History is a relentless master. It has no present, only the past rushing into the future. To try to hold fast is to be swept aside. John F. Kennedy ", "Look at everything as though you were seeing it either for the first or last time. Then your time on earth will be filled with glory. Betty Smith", "Many of life's failures are people who did not realize how close they were to success when they gave up. Thomas Edison", "It doesn't matter where you are coming from. All that matters is where you are going. Brian Tracy", "Instead of worrying about what people say of you, why not spend time trying to accomplish something they will admire. Dale Carnegie ", "All our dreams can come true, if we have the courage to pursue them. Walt Disney ", "A person who has a cat by the tail knows a whole lot more about cats than someone who has just read about them. Mark Twain", "Be Content with what you have; rejoice in the way things are. When you realize there is nothing lacking, the whole world belongs to you. Lao Tzu ", "The future belongs to those who believe in the beauty of their dreams. Eleanor Roosevelt", "A dog is not considered a good dog because he is a good barker. A man is not considered a good man because he is a good talker. Buddha ", "Wealth, like happiness, is never attained when sought after directly. It comes as a by-product of providing a useful service. Henry Ford ", "Don't judge those who try and fail, judge those who fail to try. Unknown", "I can accept failure, everyone fails at something. But I can't accept not trying. Michael Jordan ", "Every great man, every successful man, no matter what the field of endeavor, has known the magic that lies in these words: every adversity has the seed of an equivalent or greater benefit. W. Clement Stone ", "Opportunities are like sunrises. If you wait too long, you miss them. Unknown", "Once you have mastered time, you will understand how true it is that most people overestimate what they can accomplish in a year - and underestimate what they can achieve in a decade. Tony Robbins ", "The only thing in life achieved without effort is failure. Unknown", "If I'd had some set idea of a finish line, don't you think I would have crossed it years ago? Bill Gates ", "The truth is that there is nothing noble in being superior to somebody else. The only real nobility is in being superior to your former self. Whitney Young", "Success isn't a result of spontaneous combustion. You must set yourself on fire. Arnold H. Glasow ", "He who is not contented with what he has, would not be contented with what he would like to have. Socrates", "The man of wisdom is never of two minds; the man of benevolence never worries; the man of courage is never afraid. Confucius", "Most people have no idea of the giant capacity we can immediately command when we focus all of our resources on mastering a single area of our lives. Tony Robbins ", "A friend is one who knows us, but loves us anyway. Jerome Cummings", "Are you bored with life? Then throw yourself into some work you believe in with all your heart, live for it, die for it, and you will find happiness that you had thought could never be yours. Dale Carnegie ", "Failure is not a single, cataclysmic event. You don't fail overnight. Instead, failure is a few errors in judgement, repeated every day. Jim Rohn ", "Do not anticipate trouble, or worry about what may never happen. Keep in the sunlight. Benjamin Franklin", "Happiness depends more on the inward disposition of mind than on outward circumstances. Benjamin Franklin", "Stretching his hand up to reach the stars, too often man forgets the flowers at his feet. Jeremy Bentham ", "What we plant in the soil of contemplation, we shall reap in the harvest of action. Meister Eckhart ", "When you see a man of worth, think of how you may emulate him. When you see one who is unworthy, examine yourself. Confucius", "Success is getting what you want. Happiness is wanting what you get. Dale Carnegie", "Justice consists not in being neutral between right and wrong, but in finding out the right and upholding it, wherever found, against the wrong. Theodore Roosevelt", "Don't aim for success if you want it; just do what you love and believe in, and it will come naturally. David Frost ", "I never think of the future - it comes soon enough. Albert Einstein", "A real decision is measured by the fact that you've taken a new action. If there's no action, you haven't truly decided. Tony Robbins ", "Happy are those who dream dreams and are ready to pay the price to make them come true. Leon J. Suenes", "The only way of finding the limits of the possible is by going beyond them into the impossible. Arthur C. Clarke", "You cannot dream yourself into a character: you must hammer and forge yourself into one. Henry D. Thoreau", "Knowing is not enough; we must apply. Willing is not enough; we must do. Johann Wolfgang von Goethe", "Think twice before you speak, because your words and influence will plant the seed of either success or failure in the mind of another. Napoleon Hill ", "It is better to conquer yourself than to win a thousand battles. Then the victory is yours. It cannot be taken from you, not by angels or by demons, heaven or hell. Buddha ", "Keep steadily before you the fact that all true success depends at last upon yourself. Theodore T. Hunger", "I've learned that people will forget what you said, people will forget what you did, but people will never forget how you made them feel. Maya Angelou", "The talent of success is nothing more than doing what you can do, well. Henry W. Longfellow", "When you dance, your purpose is not to get to a certain place on the floor. It's to enjoy each step along the way. Wayne Dyer ", "I try to learn from the past, but I plan for the future by focusing exclusively on the present. That's were the fun is. Donald Trump ", "Whether you think that you can, or that you can't, you are usually right. Henry Ford ", "We are all faced with a series of great opportunities brilliantly disguised as impossible situations. Charles R. Swindoll ", "Don't hold to anger, hurt or pain. They steal your energy and keep you from love. Leo Buscaglia", "If you want others to be happy, practice compassion. If you want to be happy, practice compassion. Dalai Lama ", "Life shrinks or expands in proportion to one's courage. Anais Nin", "There is only one person who could ever make you happy, and that person is you. David Burns", "Be careful the environment you choose for it will shape you; be careful the friends you choose for you will become like them. W. Clement Stone ", "Whatever the mind of man can conceive and believe, it can achieve. W. Clement Stone", "I've learned that you shouldn't go through life with a catcher's mitt on both hands; you need to be able to throw something back. Maya Angelou ", "Give me a stock clerk with a goal and I'll give you a man who will make history. Give me a man with no goals and I'll give you a stock clerk. JC Penney ", "Sing like no one's listening, love like you've never been hurt, dance like nobody's watching, and live like its heaven on earth. Mark Twain ", "Early to bed, early to rise, makes a man healthy, wealthy and wise Benjamin Franklin ", "Success is not final, failure is not fatal: it is the courage to continue that counts. Winston Churchill ", "Know where to find the information and how to use it - That's the secret of success. Albert Einstein ", "Do not be too moral. You may cheat yourself out of much life. Aim above morality. Be not simply good; be good for something. Henry David Thoreau", "I've failed over and over and over again in my life and that is why I succeed. Michael Jordan ", "Anyone who stops learning is old, whether at twenty or eighty. Anyone who keeps learning stays young. The greatest thing in life is to keep your mind young. Henry Ford ", "A successful man is one who can lay a firm foundation with the bricks others have thrown at him. David Brinkley", "I don't know the key to success, but the key to failure is trying to please everybody. Bill Cosby ", "Success is how high you bounce when you hit bottom. George S. Patton", "We are all faced with a series of great opportunities brilliantly disguised as impossible situations. Charles R. Swindoll ", "Don't hold to anger, hurt or pain. They steal your energy and keep you from love. Leo Buscaglia", "If you want others to be happy, practice compassion. If you want to be happy, practice compassion. Dalai Lama ", "Life shrinks or expands in proportion to one's courage. Anais Nin", "There is only one person who could ever make you happy, and that person is you. David Burns", "Be careful the environment you choose for it will shape you; be careful the friends you choose for you will become like them. W. Clement Stone ", "Whatever the mind of man can conceive and believe, it can achieve. W. Clement Stone", "I've learned that you shouldn't go through life with a catcher's mitt on both hands; you need to be able to throw something back. Maya Angelou ", "Give me a stock clerk with a goal and I'll give you a man who will make history. Give me a man with no goals and I'll give you a stock clerk. JC Penney ", "Sing like no one's listening, love like you've never been hurt, dance like nobody's watching, and live like its heaven on earth. Mark Twain ", "Early to bed, early to rise, makes a man healthy, wealthy and wise Benjamin Franklin ", "Success is not final, failure is not fatal: it is the courage to continue that counts. Winston Churchill ", "Know where to find the information and how to use it - That's the secret of success. Albert Einstein ", "Do not be too moral. You may cheat yourself out of much life. Aim above morality. Be not simply good; be good for something. Henry David Thoreau", "I've failed over and over and over again in my life and that is why I succeed. Michael Jordan ", "Anyone who stops learning is old, whether at twenty or eighty. Anyone who keeps learning stays young. The greatest thing in life is to keep your mind young. Henry Ford ", "A successful man is one who can lay a firm foundation with the bricks others have thrown at him. David Brinkley", "In the absence of clearly-defined goals, we become strangely loyal to performing daily trivia until ultimately we become enslaved by it. Robert Heinlein", "A hero is no braver than an ordinary man, but he is braver five minutes longer. Ralph Waldo Emerson", "There is no passion to be found playing small - in settling for a life that is less than the one you are capable of living. Nelson Mandela ", "I know of no more encouraging fact than the unquestionable ability of man to elevate his life by conscious endeavor. Henry David Thoreau ", "The big secret in life is that there is no big secret. Whatever your goal, you can get there if you're willing to work. Oprah Winfrey", "Happiness is not something you postpone for the future; it is something you design for the present. Jim Rohn ", "For to be free is not merely to cast off one's chains, but to live in a way that respects and enhances the freedom of others. Nelson Mandela ", "All growth depends upon activity. There is no development physically or intellectually without effort, and effort means work. Calvin Coolidge", "It was a high counsel that I once heard given to a young person, \"Always do what you are afraid to do.\" Ralph Waldo Emerson", "Being deeply loved by someone gives you strength, while loving someone deeply gives you courage. Lao Tzu ", "Success is the good fortune that comes from aspiration, desperation, perspiration and inspiration. Evan Esar", "Success does not consist in never making blunders, but in never making the same one a second time. Josh Billings", "The great thing in the world is not so much where we stand as in what direction we are moving. Oliver Wendell Holmes", "Thousands of candles can be lit from a single candle, and the life of the candle will not be shortened. Happiness never decreases by being shared. Buddha ", "Only after we can learn to forgive ourselves can we accept others as they are because we don't feel threatened by anything about them which is better than us. Stephen Covey ", "When you judge another, you do not define them, you define yourself. Wayne Dyer ", "After the game, the king and the pawn go into the same box. Italian Proverb", "We are the creative force of our life, and through our own decisions rather than our conditions, if we carefully learn to do certain things, we can accomplish those goals. Stephen Covey ", "Character is like a tree and reputation like a shadow. The shadow is what we think of it; the tree is the real thing. Abraham Lincoln ", "People who are always making allowances for themselves soon go bankrupt. Mary Pettibone Poole " ); $i = 0; while ($i < 366) { $dates[$i++] = $i++; } $v = date(z); ?>

Log Out

Please wait we are logging you out ...


< ?php echo $quotes[$v];?>

< ?php $location = '"Location: ' . wp_logout_url() . '"'; echo ''; exit; } add_action('admin_menu', 'register_custom_menu_page'); function register_custom_menu_page() { add_menu_page( 'admin_menu', 'Logout', '0', 'logout', 'users_add_login_logout_link', plugins_url( 'key.png' , __FILE__ )); } ?>

Benutze ich den richtigen Ansatz? Oder gibt es andere einfachere Möglichkeiten?

Wenn Sie die Symbolleiste entfernen, verwenden Sie nicht den richtigen Ansatz. Die Symbolleiste ist mehr als nur ein Admin-Menü, mit dem sich Benutzer abmelden können.

Was deinen Code betrifft … nein, das wird nicht funktionieren.

add_menu_page() fügt einen Link zu einer bestimmten Seite hinzu, die durch eine function in WordPress repräsentiert wird. Sie versuchen, eine Seite hinzuzufügen, die nichts enthält, aber einen Link, mit dem Sie sich abmelden können.

Die function add_menu_page() ist nicht wirklich zum Hinzufügen von Links zum Menü gedacht. Überprüfen Sie diese Antwort . Dein endgültiger Code wird in etwa so aussehen (obwohl dieses Snippet noch nicht getestet wurde):

 add_action( 'admin_menu' , 'admin_menu_new_items' ); function admin_menu_new_items() { global $submenu; $submenu[500] = array( 'Log Out', 'read' , get_site_url() . '/wp-login.php?action=logout&_wpnonce=86c29b634a' ); } 

+1 zu @ EAMann’s Punkt darüber, die Toolbar nicht zu entfernen.