One of our users is having a terrible getting posts to show up, because the system isn't assigning the post to a template by default. Everything seemed to be working fine for me, but through some testing, I've discovered that if someone types in a Title, then goes directly to click the Publish button, the Template doesn't get assigned. Maybe this assignment method has to fire before the Publish button is clicked, but it is a problem when the user doesn't click anywhere outside the Title box before clicking Publish.
Hi, can you tell me if any Layout is assigned to this post type? If you go to Toolset > Dashboard, look in the Template column and find the row for the post type your users are creating. Is a Layout assigned here? If not, does it make sense to assign a default Layout, just in case the users do not select one in the post editor? If there is a Layout assigned in the Dashboard, we need to investigate further:
Can you take a screenshot of the post editor screen just as it loads when your user attempts to create a new post? I would like to see the Layout settings applied in this page.
Also look in the browser console when the post editor screen loads. Are any JavaScript errors shown? If so please copy + paste them or take a screen shot for me to review.
Thanks for the reply. Yes, the layout is assigned to the post type. I've attached a screen capture. When the "Create New" page loads, the correct layout is automatically selected in the dropdown menu on the right. The problem occurs after that, when the post is made a specific way. Through some testing (while trying to figure out why the user was having trouble, but not me), I discovered that if you type in a Title, then go directly and click Publish (without clicking outside of the Title box), the system doesn't create the relationship for the new post. If you do click outside of the Title box, the script seems to process correctly and everything links up. I've informed the user to just click into the description box (below the title box), prior to publishing the post, and that is working for him now...but if he forgets, it's going to cause problems again.
I would think this may occur for you too. Basically, if you type in a Title when adding a new post, then go directly to and click the Publish button (the WordPress permalink won't even be created under the Title yet, because you haven't clicked outside the Title box to activate that script), you should be able to go view your new post and see that it wasn't linked to the Template.
I'm fairly new to php/WordPress and am more of a C# developer, but it's like the script to create the relationship to the post must run after a Title is entered (much the same way the permalink creates after clicking outside the Title box), but must not activate and run from an On_Click type event of the Publish button.
I'm actually not able to replicate this issue on a clean site installation, following your instructions about how to publish the post. I wonder if something else is going on. Please try the following steps for me:
- Temporarily disable all non-Toolset plugins and activate a default theme like 2017. Test again.
- If the problem is resolved, reactivate your theme and plugins one-by-one until the conflict is revealed.
- If the problem is not resolved, I will need to take a look in your wp-admin area and probably make a clone of your site to run some more tests. If that's okay, please provide credentials in the private fields here.
This issue has come up again with the same client, and I've done some more testing, which may have narrowed down the cause of the issue. I went through and turned off plugins and attempted to create a post by entering a title, then going straight to the Publish button, but the issue still occurs. Upon further testing, it seems that if you are an Administrator this issue doesn't happen. His role is an Editor, so I think the glitch is related to the Editor role. When the post is being created as an Editor, the Template Layout dropdown/box is there, but disabled. At first you can see the correct template is selected (though grayed out and disabled), but after entering the title and going straight to the Publish button and publishing it, the template is no longer selected. It seems like this being disabled is causing a problem assigning when the post is made without giving the page a chance to create the permalink or auto-save before the publish method occurs.
Hi, thanks for the clarification on this. I was able to replicate the same issue when logged in as an Editor, so I have reported this inconsistency to our 2nd tier supporters for additional investigation. Please stand by and I will update you when I have more information to share.
Hi, our 2nd tier support team has offered the following solution:
- Activate Toolset Access
- Go to Access > Custom roles
- Enable Advanced mode
- Click "Change permissions" under the Editor role
- Click Layouts capabilities
- Enable all the available capabilities there
Please let me know if this does not resolve the issue and I will take a closer look, but it did appear to solve the problem locally.
Thanks for looking into this, Christian. Using an access manager works as a band-aid, but now I need to hide that whole Template Layout box from the Editor role. My concern is that they are going to accidentally change the template, click the create new template link (which will create a new one and a big issue, since that post type wouldn't automatically assign to the correct one anymore), or click the "Stop using this Template Layout." Is it best to just set the div to hidden somehow?
We ended up adding a class for users who can't activate plugins (since the editor can't), then added a stylesheet to the admin_head which contained a style the hid the .cannot-activate-plugins #wpddl_template{display:none;}
This seems to have the issue patched for now.
--------------------------------------------------------------------------------
///////////////////////////////////////////////////////////////////
// ADD CUSTOM CLASS TO BODY FOR USERS WHO CAN'T ACTIVATE PLUGINS //
///////////////////////////////////////////////////////////////////
function jn_admin_body_class( $classes ) {
global $wpdb, $post;
if ( !current_user_can('activate_plugins') ) {
$classes .= 'cannot-activate-plugins';
}
return $classes;
}
add_filter( 'admin_body_class', 'jn_admin_body_class' );
//////////////////////////////////////
// ADD STYLESHEET FOR THE DASHBOARD //
//////////////////////////////////////
add_action( 'admin_head', 'dashboardcss' );
function dashboardcss() {
echo "<link rel='stylesheet' media='screen,projection' type='text/css' href=" . get_stylesheet_directory_uri() . "/admin-style.css>";
}
------------------------------------------------------------------------------
****************************************
style in the stylesheet
****************************************
.cannot-activate-plugins #wpddl_template{
display:none;
}