Wordpress: why is one of my users unable to edit other author's posts? - wordpress

I have a wordpress website with several different authors and two admins, of which I am one. I have attempted to promote one of my authors to an editor and then an admin so she can edit other authors posts. But it isn't working. She can edit her own posts, but when she goes to edit somebody else's post she can't change anything, preview button is disabled.
I and the other admin are able to edit others posts with no problems.
What do I need to do to allow my new editor to edit posts from other authors?
Edit: I should mention that I tried the User Role Editor plugin to see if that would improve things, but it says my editor user should have the right permissions to preview, save and publish other people's posts.
Edit: Another thing I should have mentioned is that I installed the 'Hide My WP' plugin to block hackers -- and that appears to be the source of my problems. I put details into my answer below.

Wordpress summary of roles:
Super Admin – somebody with access to the site network administration features and all other features. See the Create a Network article.
Administrator – somebody who has access to all the administration features within a single site.
Editor – somebody who can publish and manage posts including the posts of other users.
Author – somebody who can publish and manage their own posts.
Contributor – somebody who can write and manage their own posts but cannot publish them.
Subscriber – somebody who can only manage their profile.
Adding special role.
First make sure you are using a child theme. In your function.php file put this piece of code.
//Add a custom user role
$result = add_role('userx', __('UserX'),
array(
'read' => true,
'edit_posts' => true,
'edit_pages' => true,
'edit_others_posts' => true,
'create_posts' => true,
'manage_categories' => true,
'publish_posts' => true,
'edit_themes' => false,
'install_plugins' => false,
'update_plugin' => false,
'update_core' => false
)
);
Note: If permission aren't working, It's maybe because the codes that handle permissions are modified. To make it easier and solve the problem, look for a plugin like User Role Editor and install it.

I figured out the problem so I figured I'd share it here for future sufferers. It turns out that the security on my 'Hide my WP' plugin was turned up too high, I turned off the IDS firewall for frontend+backend and made it 'frontend' only. Voila, all of my users are able to edit posts again!

Related

Wordpress user frontend Plugin Posts listing order by title?

We are using "Wordpress user frontend Plugin" in our site to create, edit posts from frontend.
There we need a feature which is not implemented in the plugin we guess.
We need to show the posts listing by their titles regardless of their creation date.
Can it be possible?if yes, then can please let us know the correct way of using an action hook or filter rather than made the changes directly on the plugin files itself.
Really needed a quick response,already spending a lot of hours for this one.
Thanks,
You'll need to edit the index page, including 'orderby'=> 'title' in the correct place.
A quick google search will find the exact answer you need. Do your research.
finally after going through the plugin(Wordpress user frontend) files.
I got this filter "wpuf_dashboard_query".
applied my necessary changes to it and it worked.
add_filter('wpuf_dashboard_query','wpuf_posts_sort_by_title');
function wpuf_posts_sort_by_title($args){
$data = array_merge($args, array('orderby'=> 'title', 'order' => 'DESC'));
return $data;
}

Wordpress post to user relation ship

Is there any way to connect post to specific user in wordpress. Is there any plugin available. Or any one know the code for doing that.I have a custom post type stories. When adding stories i need to chose the corresponding users from user list. Please help
Install Post2post https://wordpress.org/plugins/posts-to-posts/
Then in your function.php write this code
p2p_register_connection_type ( array(
'name' => 'releated_user',
'from' => 'story',
'to' => 'user'
) );
here story is your custom post type slug. related_user is just a connection name.You can name it as what you like.
Then in your post type section you can see an option for selecting corresponding user.
In the custom post type setup, you first need to ensure that this post type allows for authors to be set.
This comes in from the arguments when registering the post type.
$args = array('supports'=>array('author'=>true));
If you have an admin account, you can set who the author is using the quick edit function or by allowing to see it under screen options on the full edit page.
Other than that, you can make your own complete post meta box to allow for multiple authors. I cant see a plugin on the wordpress plugin directory so creating your own to fit your needs and wants will be your best bet.

Mixing Wordpress 3.7.1 Page Templates and Custom Post Types

Overview
I have a Custom Post Type called Locations. When the user visits /locations, I would like them to see some general information about all the locations. When the user visits /location/{a-location}, I would like them to see specific information about "a-location". Sounds easy enough.
1st Solution Attempt
I created a Locations page in the Wordpress dashboard to hold the content for the /locations url. I then created an archive-locations.php file and a single-location.php. archive-locations.php pulls info out of the Locations page and it lists all of the custom post type Locations. When the user clicks on a link for a location, the user gets redirected to /locations/{a-location} and single-location.php gets called. This almost does the trick, but it just doesn't feel right and it's creating some other problems.
The Problem
When a user visits /locations I would prefer to be working with a page template for the Locations page (instead of the archive-locations.php page). I'm using the Yoast plugin to specify a custom meta title and description for each page. Since archive-locations.php is being used, all of this meta gets ignored.
2nd Solution Attempt
So I created a page-locations.php template for the Locations page and I was hoping that it would get called instead of the archive-locations.php. Unfortunately, it does not. I then tried removing the archive-locations.php thinking that maybe it was taking precedence. That didn't help either; Wordpress simply renders index.php. If I disable the Custom Post type and visit /locations, then my page template is called correctly. It looks like naming a custom post type the same name as a page causes Wordpress some issues. However, I need to be somewhat similar for the URL structures to work out. /locations needs to pull from a page template; /locations/{a-location} needs to pull from another php pfile.
Question
Is there any way to get page templates and custom post types with similar slugs to work together? If not, I guess my only option is to enhance my header.php and be smarter about determining the title and description when I'm on /locations.
Here's the code that registers my custom post type in case I'm doing something wrong:
$args = array(
'labels' => $labels,
'description' => 'Holds our location specific data',
'public' => true,
'menu_position' => 20,
'supports' => array('title', 'editor', 'thumbnail', 'page-attributes' ),
'hierarchical' => true,
'has_archive' => true,
'rewrite' => array('with_front' => false, 'slug' => 'locations') //remove /news/ from the permalink when displaying a custom post type
);
register_post_type( 'locations', $args );
(I also tried changing has_archive to false, but it didn't help.)
What you are trying to do, I once managed to get done easily. I mean having custom post type and use its slug with cusotm page.
Did you try to flush rewrite rules? (just visit Permalink page and save the rules as they are)
So I created a page-locations.php template for the Locations page and I was hoping that it would get called instead of the archive-locations.php. Unfortunately, it does not. I then tried removing the archive-locations.php thinking that maybe it was taking precedence. That didn't help either; Wordpress simply renders index.php
You do not write, how do you load your page template. Do you rely on automatic WP connection of pageslug and page-pageslug.php or you set page template through Page attributes menu?

Administration menu

I'm looking for some beginners resources for drupal. I've been writing my own module as a way of teaching myself the basics of development as I like the idea of having Drupal to go to when Wordpress can't manage. (Although wordpress is fast becoming as accomplished as Drupal, but that's not what the questions about.)
I have the module showing up in the enable/disable screen and the module.install file works a treat. What I'm stuck on is generating an admin area to edit entries in the table I'm using. I have a module_admin_settings() function in module.admin.inc, plus module.menu () in module.module.
But it isn't appearing in the menus and I'm stumped as to why that is. So I'm hoping someone knows a good tutorial that explains how to generate admin options.
If you want to become serious with Drupal development, I would advice you to go through the Pro Drupal developemnt book. It has been the single most helpful Drupal book I have ever read.
As for your question, to create a admin section is not much different from creating a view some where. What you need to do is.
Implement hook_menu to register the url you want to use, in your case admin/settings/name should be fine
Implement a call back function that should be called when a user go to the your. In your case you don't need to implement one as you should use drupal_get_form, but instead you need to create the form that the user should see using the form API.
You need to place this info in your hook_menu like this:
function modulename_menu() {
$items = array();
$items['admin/settings/modulename'] = array(
'title' => 'Menu item',
'description' => 'The description of the menu item. It is used as title attribute and on the administration overview page.',
'page callback' => 'drupal_get_form',
'page arguments' => array('form_id'),
'access arguments' => array('administer modulename'), // access restriction to admins only
);
return $items;
}
Then you need to implement validation and submit handlers for your form, is you use a system_settings_form, you can get a lot of the work done for you.
Whenever you make changes to hook_menu, you need to clear the (menu) cache, as Drupal caches this information to optimize performance.
That's it. Now you don't need to use different files in your module. If the module is small all could just go into the .module file. But for bigger modules, you can place some of your code in .inc files to organize your code a bit. Fx modulename.admin.inc for your admin callbacks/functions, modulename.page.inc for your regular callback/functions etc.
http://drupal.org/node/206761 is what I use as a starting point.

Creating "ON/OFF News Links" functionality for a block created with View Module

I'm a drupal newbie who needs some advice...
I have a news list block at homepage, created with View Module. It is listing all added news' title and link. Everything is cool so far. Now I need to add an ON/OFF option at admin side for homepage news block. When the setting is ON, it will work as it is. When it is OFF, only the titles will be listed with no linking to news detail page.
So, now where should I add this ON/OFF option? I have only add/edit/delete pages for each news, there is no common news page to add such option. Should I create an admin page with such ON/OFF option in? Also I think I need to create a db table to keep this ON/OFF status. and controlling this value at homepage block, if it is 1 or 0, and displaying links according to db value :/
it looks too long way
Create db table
Create an page with ON/OFF option in
add php codes to update db for admin's choice
get the db value in homepage block to display links, etc.
is there any shorter, better way to do what I need?
Appreciate helps so much!!! Thanks a lot!!
You definitely don't need to create any database tables for something like that. If you want a basic admin page, you will need to write a simple module though. First follow this quick start guide for setting up a basic module. (Note: You don't need to add those database queries in your .install file)
Once you have your module enabled...
1) In your mynewmodule.module file, add a menu entry to tell Drupal where your admin page can be accessed:
function mynewmodule_menu() {
return array(
'admin/settings/mynewmodule' => array(
'title' => 'My New Module',
'description' => 'Change settings for news display.',
'page callback' => 'drupal_get_form',
'page arguments' => array('mynewmodule_admin_form'),
'acces callback' => 'user_access',
'access arguments' => array('administer site configuration'),
),
);
}
2) Also in your mynewmodule.module file, add a function to create the form you just referenced in the menu entry:
function mynewmodule_admin_form() {
$form = array();
$form['mynewmodule-on-off-switch'] = array(
'#type' => 'checkbox',
'#title' => t('Enable news links'),
'#description' => t('Control whether news items are linked to stories'),
'#default_value' => variable_get('mynewmodule-on-off-switch', 1),
);
return system_settings_form($form);
}
3) Clear your cache to make Drupal recognize your admin page (you need to clear any time you make changes to mynewmodule_menu()). You can clear it here: admin/settings/performance
4) Visit admin/settings/mynewmodule to see your admin form. The way it works is when you save the configuration, Drupal will save a variable called "mynewmodule-on-off-switch" (same name as the array key in the form) to the variables table in the database. You can get this value anywhere by using variable_get().
create a form at admin/settings/on-off-switch.
on the form submit function, variable_set('on/off switch', $value) (try using booleans for the value).
then on the view theme, check for variable_get('on/off switch', $default_value) before printing the links.
Drupal's weakness, IMHO, is the sheer number of admin settings to configure to get a site up, and you don't want to be adding to that.
What I would do is to have the view expose two different blocks, one with the full view, one with the abbreviated view. Then all the configuration can be done through the block interface, which will be much more flexible in the long run. By, for example: using wildcards or php code for block visibility; showing different views to users with different roles; allowing visitors to control which view they see; exposing the two views to the theming engine more cleanly; and integration with any other module that works with blocks.

Resources