Need some help modifying code snip-it

I need this snip changed to where "EACH" user can only publish one "PAGE" and be able to edit that page.

Don't want others to be able to edit it, only the user, and admin/network admin.

If it has to be done by post and not page, then so be it!

I have tried many plugin for this,to no evial.

Just want to put it in a theme and have a cheesy grin on my face when it works.

Got some point for a working snip-it

How you been @maxaud, :slight_smile:

<?php
/**
* New Post Administration Panel.
*
* @package WordPress
* @subpackage Administration
*/

/** Load WordPress Administration Bootstrap */
require_once('admin.php');
$title = __('Add New Post');
$parent_file = 'edit.php';
$editing = true;
wp_enqueue_script('autosave');
wp_enqueue_script('post');
if ( user_can_richedit() )
wp_enqueue_script('editor');
add_thickbox();
wp_enqueue_script('media-upload');
wp_enqueue_script('word-count');

if ( ! current_user_can('edit_posts') ) {
require_once ('./admin-header.php'); ?>
<div class="wrap">
<p><?php printf(__('Since you’re a newcomer, you’ll have to wait for an admin to add the edit_posts capability to your user, in order to be authorized to post.
You can also e-mail the admin to ask for a promotion.
When you’re promoted, just reload this page and you’ll be able to blog. :)'), get_option('admin_email')); ?>
</p>
</div>
<?php
include('admin-footer.php');
exit();
}
//limit the quantity to N posts
$N = 20; max 20 posts por usuario
$count_posts = count(get_posts(array('author'=>$user_ID)));// returns the quantity of written posts by current user to $user_ID
if ($count_posts >= N){
Header("Location: index.php");//redirects to dashboard, where it should point the user that he cannot create a new post
}
//end of modification

// Show post form.
$post = get_default_post_to_edit();
include('edit-form-advanced.php');

include('admin-footer.php');
?>

Thank You!

  • Tyler Postle
    • CGO

    Hey again Mark!

    Is this for each person to have their own profile style page? What sort of content will they be editing? This might help in determining the best route to take here.

    There are quite a few profile page plugins out there; however, noticing that your using BuddyPress already - I'm thinking you have something else planned for this page.

    Let us know then we'll look into the best solution for this :slight_smile:

    Talk to you soon,
    Tyler

  • Mark Wallace
    • Learn-ing-er

    I just want a regular page for each user.

    I used user role manager > role scope > a couple front end managers. all see, to fail, and are not well supported.

    Many others I tried work well for post, but not pages.

    Would rather just create a child theme since it is for just one sub site on the network.

    Thanks Tyler!

    • Tyler Postle
      • CGO

      Hey Mark,

      Makes sense! The reason it is a bit tough to do is because posts/pages both use the same user role capability to edit - you likely already knew that. Anyways, I will call in SLS(coding experts) on this one to get their valuable input :slight_smile: Perhaps they will be able to custom code a solution here.

      In the meantime, we'll continue to work with you through your other questions :slight_smile:

      Cheers,
      Tyler

  • Saurabh
    • New Recruit

    Hi @Mark Wall,

    Hope you are well today!

    SLS is just second level support, jargon to be blamed!

    The snippet that you have pasted above is over 5 years old and is meant to replace the post-new.php from WordPress core, which is not recommended, at all.

    On a quick google search for limit number of posts per user wordpress, I found:

    http://wordpress.org/plugins/bainternet-posts-creation-limits/

    and some more code and plugins floating here and there. I haven't tested these, but feel free to try this one or the others out.

    Do let us know how it works for you, so other members of the community looking for a solution may be able to benefit from it.

    Best

    Saurabh

  • Mark Wallace
    • Learn-ing-er

    Yeah i tried that one, even when set to page; it only does post. "just tried it again"
    I have tried many of them, so many i ended up trying the same ones multiple times! lol

    Just to help me understand something! If profiles are set up the same way as I am trying to do.
    Then why is it so hard to do this? Wouldn't it be the same thing really?

    Thanks for the reply!

Thank NAME, for their help.

Let NAME know exactly why they deserved these points.

Gift a custom amount of points.