• Hello, newbie here;

    I’m looking for a way to check a users capabilities (or even if they’re logged in), but seem to be hindered by the scope on the server.

    WordPress is installed in a directory off the root:
    https://www.domain.com/wordpress/

    But I want to check in a file on the root if the user is already logged in to WordPress.
    https://www.domain.com/test.php

    Now, I can use current_user_can() etc. if I were checking in the WordPress directory, but as soon as you leave that it says you’re not logged in.

    Is there a way round this or is it just a security thing? Sorry if it’s obvious, but I’m rather new to all this and not a particularly good coder either.

Viewing 1 replies (of 1 total)
  • Hi there,

    such an function would be really good.

    Until something will be integrated you could use something like that, to check the rights of the logged in user and show him the edit-link of a post with a certain ID:

    <?php
    if (current_user_can('edit_post', $post->ID)) {
    echo "&middot; <a href='" . get_bloginfo('wpurl') . "/wp-admin/post.php?action=edit&post={$post->ID}' class='edit'>" . "edit</a>";
    }
    ?>
Viewing 1 replies (of 1 total)
  • The topic ‘Checking user capabilities’ is closed to new replies.