• I was looking for the ability (in other plugins) to a way to restrict users who have the ability to edit posts or pages to not be able to edit specific posts or pages. In particular, I don’t want anyone to edit my frontier post shortcodes!

    I realized that because Frontier Post changes the URL for the Edit link at the bottom of the page, I could use that function in FP to check for a Custom Field.

    More specifically, the function frontier_edit_post_link( $url, $post_id ) in frontier-post.php

    If I add something like:
    $restrict_edit = get_post_meta( $post_id, ‘fp_restrict_edit’, true );
    echo “EDIT RESTRICTED: “;
    if ($restrict_edit) {
    $url = ‘/’;
    return $url;
    }

    right after checking for whether the user is admin, then I can restrict access to anyone but admin from editing a page/post/whatever by simply adding a custom field “fp_restrict_edit” to any page I don’t want someone to edit. this would be a super easy function to add to this plugin that would address a complicated problem for people, and let them protect those complex FP shortcodes.

    Adding this will do the same thing:
    function rgs_edit_post_link( $url, $post_id )
    {
    // Remove the link if a custom field is restrict_edit
    // to be used on pages/posts with custom shortcodes to prevent
    // them being screwed up
    $restrict_edit = get_post_meta( $post_id, ‘restrict_edit’, true );
    if (!$restrict_edit || current_user_can(‘administrator’)) {
    return $url;
    } else {
    echo ‘EDIT RESTRICTED’;
    }
    }
    add_filter( ‘get_edit_post_link’, ‘rgs_edit_post_link’, 15, 2 );

  • The topic ‘Ability to create restricted individual pages/posts’ is closed to new replies.