Улучшаем работу с wordpress
Прошу прощения за день простоя(луч поноса джино.ру).
Сегодня Я хочу рассказать Вам как облегчить себе работу с популярным у блогеров cms wordpress.
Всегда удобнее иметь самые используемые функции у себя под рукой, для этого я создал себе дополнительный блок, который виден только для меня(администратора).
Такой блок делается с помощью стандартной функции wordpress — current_user_can(), которая решает показывать или не показывать данные пользователю в зависимости от его прав на блоге.
Права пользоватей:
- Подписчик : level_0
- Участник: level_1
- Автор: level_2
- Редактор: level_3 - level_7
- Администратор: level_8 - level_10
К примеру, для показа блока только для администратора используем функцию следующим образом:
<?php if (current_user_can('level_10')){ ?>
<ul class="admin_box">
<?php wp_register(); ?>
<li><a href="<?php echo get_settings('home'); ?>/wp-admin/post-new.php">Создать новую запись</a></li>
<li><a href="<?php echo get_settings('home'); ?>/wp-admin/page-new.php">Создать новую станицу</a></li>
<li><a href="<?php echo get_settings('home'); ?>/wp-admin/options-general.php">Настройки</a></li>
<li><?php wp_loginout(); ?></li>
</ul>
<?php }?>
Кроме того эту функцию можно использовать и наоборот, для скрытия ненужных блоков, которые нужны для пользователя, но не для администратора.
К примеру:
<?php if (!current_user_can('level_10')){ ?>
/* Этот блок будет отображатся для всех кроме администратора */
<?php }?>
Можно найти еще множество способов для применения этого приема, но лучше всего готовить это с функциями is_single(), is_page(), is_category() и другими :-)
Всем удачного дня! В следующий раз расскажу как сделать удобное комментирование, как у меня в блоге.

Спасибо, я только начинаю разбираться с WordPress, и такие «маленькие хитрости» очень кстати.
спасибо! тоже интересуюсь этой платформой. цикл статей про вордпресс не помешает
Спасибо!! Сегодня обязательно попробую!!!
Там ошибка, надо вместо «Админ есть — бог» написать «Админ — бог» или «Админ есть бог» :)
Ага, статеек по настройке WP как то маловато.
Кстати вопрос, а что означает(в чём смысл) пункт «Произвольные поля» при доваблении новости?
Да знаю, очень интересная вещь на самом деле, Максим(maxsite.org) как то писал по этому поводу. Думаю и мне стоит как-нибудь об этом написать :-)
Да ладно, эту ошибку вижу только Я, и меня она вполне устраивает :-)
Спасибо, как раз то что я искал :)
Спасибо за подсказку. Полезно.
Только как ее реализовать?
Куда вставить код?
Подскажите уж и это для совсем начинающих.
Код вставляется в нужное Вам место в нужной Вам теме оформления.
Вставила.
На странице ничего не появилось.
Что я делаю не так?
Пожалуйста, расскажите по шагам.
Если Вы вставили первый код, то у Вас должно появится меню, которое видно только для Вас(админисратора).
Спасибо, Разобралась
Отличная статья.
Было очень интересно читать.
Спасибо.
Поди второй пункт в админке самый кликабельный? )))
хм, прикольно
Хорошая штука, но расскажи несведущему – куда ставить пхп код, в sidebar.php?
Получилось просто и понятно. Спасибо!
Информация полезная, использовал для скрытия выбора редактора в профиле. Жаль что после обновления все переделывать приходится.
the plot of land lines are very mundane.
I simply want to mention I’m newbie to blogs and absolutely liked your website. Very likely I’m planning to bookmark your blog post . You really come with fantastic posts. Appreciate it for sharing your website page.
I discovered your blog site on google and check a few of your early posts. Continue to keep up the very good operate. I just additional up your RSS feed to my MSN News Reader. Seeking forward to reading more from you later on!…
Your place is valueble for me. Thanks!…
An interesting discussion is worth comment. I think that you should write more on this topic, it might not be a taboo subject but generally people are not enough to speak on such topics. To the next. Cheers
Hello! I just would like to give a huge thumbs up for the great info you have here on this post. I will be coming back to your blog for more soon.
Excellent read, I just passed this onto a friend who was doing a little research on that. And he just bought me lunch as I found it for him smile Therefore let me rephrase that: Thanks for lunch!
Heya i’m for the first time here. I came across this board and I find It truly useful & it helped me out much. I hope to give something back and aid others like you helped me.
Do you mind if I quote a few of your posts as long as I provide credit and sources back to your webpage? My blog is in the exact same niche as yours and my visitors would genuinely benefit from a lot of the information you provide here. Please let me know if this ok with you. Thank you!
Excellent read, I just passed this onto a friend who was doing a little research on that. And he just bought me lunch as I found it for him smile Therefore let me rephrase that: Thanks for lunch!
An impressive share, I simply given this onto a colleague who was doing a little bit evaluation on this. And he in truth bought me breakfast as a result of I discovered it for him.. smile. So let me reword that: Thnx for the deal with! However yeah Thnkx for spending the time to debate this, I really feel strongly about it and love reading more on this topic. If potential, as you turn into experience, would you thoughts updating your weblog with extra details? It is highly helpful for me. Huge thumb up for this weblog submit!
Aren’t getting Scamed buying Male Extra
Where you should buy Male Extra
Greatest slim weight patch,,Best slimweight patch,review article of the slim weight patch ,2012 slimweight patch review ,slim weight patchhottestreview,
I’m really loving the theme/design of your internet site. Do you ever run into any browser compatibility difficulties? A number of my weblog readers have complained about my web site not operating correctly in Explorer but looks wonderful in Opera. Do you’ve got any solutions to assist fix this issue?
Oh my goodness! an amazing write-up dude. A lot of thanks Even so My business is experiencing trouble with ur rss . Do not know why Struggle to sign up to it. Can there be everyone acquiring identical rss dilemma? Anyone who knows kindly respond. Thnkx
I view something genuinely unique in this web site .
Excellent read, I just passed this onto a colleague who was doing a little research on that. And he actually bought me lunch because I found it for him smile Thus let me rephrase that: Thanks for lunch! «They may forget what you said, but they will never forget how you made them feel.» by Carl W. Buechner.
I like this blog very much so much excellent information. «The worst solitude is to be destitute of sincere friendship.» by Francis Bacon.
I like this web site very much, Its a rattling nice position to read and get info. «Youth is a wonderful thing. What a crime to waste it on children.» by George Bernard Shaw.
I like this internet site because so much utile material on here : D.
Do y0u mind iff I qu0te a few of your articles as long as I provide credit and sources back to your website? My website is in the exact same niche as yours and my visitors would genuinely benefit from some of the information you provide here. Please let me know if this okay with you. Thank you
I really appreciate this post. I’ve been looking everywhere for this! Thank goodness I found it on Bing. You have made my day! Thank you again!
Wonderful goods from you, man. I’ve understand your stuff previous to and you’re just extremely magnificent. I actually like what you have acquired here, really like what you’re stating and the way in which you say it. You make it enjoyable and you still take care of to keep it wise. I cant wait to read far more from you. This is actually a tremendous site.
Hello there, I found your site by way of Google at the same time as searching for a related topic, your site came up, it seems great. I’ve bookmarked it in my google bookmarks.
You really make it appear really easy along with your presentation however I to find this matter to be really something that I believe I might never understand. It kind of feels too complicated and extremely extensive for me. I’m looking forward in your subsequent publish, I¡¦ll try to get the dangle of it!
Thanks for another informative site. Where else could I get that kind of information written in such an ideal way? I’ve a project that I am just now working on, and I’ve been on the look out for such information.
There are certainly a lot of details like that to take into consideration. That is a great point to bring up. I offer the thoughts above as general inspiration but clearly there are questions like the one you bring up where the most important thing will be working in honest good faith. I don?t know if best practices have emerged around things like that, but I am sure that your job is clearly identified as a fair game. Both boys and girls feel the impact of just a moment’s pleasure, for the rest of their lives.
Just the article I was hoping to see! Thanks! I discovered your blog site site online and check a number of your early on posts. Keep up the really good operate. I recently additional increase RSS feed to help my Yahoo News Viewer. Seeking forward to reading extra from you down the line!…
An interesting discussion is worth comment. I think that you should write more on this topic, it might not be a taboo subject but generally people are not enough to speak on such topics. To the next. Cheers
Heya i’m for the first time here. I came across this board and I find It truly useful & it helped me out much. I hope to give something back and aid others like you helped me.
An impressive share, I just given this onto a colleague who was doing a little analysis on this. And he in fact bought me breakfast because I found it for him.. smile. So let me reword that: Thnx for the treat! But yeah Thnkx for spending the time to discuss this, I feel strongly about it and love reading more on this topic. If possible, as you become expertise, would you mind updating your blog with more details? It is highly helpful for me. Big thumb up for this blog post!