The MU forums have moved to

is_user_logged_in() ?? is_ACTUAL_user_permitted_to_edit ?? (6 posts)

  1. sepp88
    Posted 14 years ago #

    hi there,

    i have a simple question, just wanna know if it's possible or not!
    i'm using this bit of code underneath every post to give a USER the ability to edit a blogpost directly by clicking on the edit button.
    <?php if(is_user_logged_in()) { ?> / <?php edit_post_link('EDIT', '', ''); ?><?php } ?>

    however, is there any other way for WPMU to kind of query if the USER is even permitted to EDIT this particular post. for instance, i have a certain USER which can only EDIT and MANAGE a certain subblog in my MU-environment.

    i just want to make the EDIT button visible if this USER is on his blog.

    if i use this code mentioned above, any user of any subblog sees the EDIT button on the MAINBLOG.

    can i change that?

  2. DeannaS
    Posted 14 years ago #

    There's a built-in function that manages all that. It's this:

    edit_post_link('Edit', '', ' | ');

    If a user can edit a post, it will display a link - in this case the text linked will be "Edit" and it will be followed by a '|' and it will use the current post id of the loop to determine if the user can edit the post.

    There's also this:

    current_user_can( 'edit_post', $post->ID )

    This will just return true or false.

  3. sepp88
    Posted 14 years ago #

    thank you will try that! is there a way to get the "EDIT" and the "|" swapped.

    like " | Edit" instead of "Edit | "??

    and what i actually meant is...for instance. i have a mainblog and a few subblogs, all of them use the same theme-templates. my sidebar has inclued kind of a meta, where you can "Jump to the Dashboard", "Add a new post" or "Logout"... i've set that meta like mentioned above with the is_user_logged_in()...this means it only appears if a user is logged in. however if a certain user which is only allowed to edit a subblog visits the mainblog, he can see the META as well. i only want every USER to see only the meta of the blog he is belonging to.

    is there any way to implement that?

  4. sepp88
    Posted 14 years ago #

    it works this way:

    <?php edit_post_link('', '', '|'); ?>
        <?php edit_post_link('Bearbeiten', '', ''); ?>

    but maybe there's a better solution!?

  5. sepp88
    Posted 14 years ago #

    thank you! it works fine for me! don't need that other thing. works perfectly for me now. love it!

    thank you for your awesome help!

  6. DeannaS
    Posted 14 years ago #

    Um, your best friend is the codex. Or, just looking at the code. But, for reference, here's what you want (not what you put up there):

    <?php edit_post_link('Bearbeiten', '|', ''); ?>

    The first parameter is the word to be linked. The second parameter is any text that should output before the link. The third parameter is any text that should output after link. There's an optional fourth parameter that controls which post_id you're linking to.

    And, here's the codex page.

About this Topic