• Hi! I hope someone can give some help..
    Sorry i can’t give the site address because it Is a security issue (template problem).
    we need a control code to limit editing access for the author only to this page (it is a frontend page w/forms but connected to wordpress backend). Currently ANY author/registered user can modify the data, a big problem .

    the code I use:

    <?phpglobal $current_user;
    get_currentuserinfo();
    $user = $current_user->user_login;
    $email = $current_user->user_email;
    $name = $current_user->display_name;
    $idu = $current_user->ID;
    $ida = get_the_author_id(); ?>
    <?php if $idu != $ida { echo 'user not authorized'; } else { echo '': }?>

    the code is not working..

    any help please?

Viewing 6 replies - 1 through 6 (of 6 total)
  • Thread Starter gastrog

    (@gastrog)

    p.s only the author or admin should have access to the page

    Try this

    <?php
    $current_author = get_the_author_meta('nickname');
    global $current_user; get_currentuserinfo();
    if ($current_user->user_level == 10 || $current_user->nickname == $current_author) { ?>
    
    	---hidden things---
    <? }?>

    Thread Starter gastrog

    (@gastrog)

    Hi, Silafu and thanks for your reply!
    Your code seems to work fine for the admin but not for the author. Even the author gets restricted access. Could there be some work around? I’m not php programmer (unfortunately) ??

    Regards

    Thread Starter gastrog

    (@gastrog)

    I’ve also tried this code:

    <?php
    $prop_autore = get_the_author_meta('ID');
    global $current_user;
    get_currentuserinfo();
    if ($current_user->ID == $prop_autore) { ?>

    Using ID instead of nick name but but no good news!

    Any hint?

    anyone have solved?

    i’ve the sampe problem, if i use this code:

    <?php
    $current_author = get_the_author_meta('nickname');
    global $current_user; get_currentuserinfo();
    if ($current_user->user_level >7 || $current_user->nickname == $current_author) { ?>
    
    <!-- the posts -->
    
    <? }?>

    admin see all post, and for me its ok. but, the author pf the post can see only the today post and not ALL his posts…
    ??

    i’ve solved with another solutions…

Viewing 6 replies - 1 through 6 (of 6 total)
  • The topic ‘Current user and auhor’ is closed to new replies.