0

If i add new post, the current user i selected and saved. Now i have imported dummy data via XML import, and i need after editing the post, save the current-actually logged user.

screen here : ibb.co/hrGUGF ibb.co/fXZGwF

original:

<?php    
    return array(
        'author' => array(
            'label'        => __('Author', 'ait-toolkit'),
            'type'         => 'select-dynamic',
            'dataFunction' => 'AitItemCpt::fillAuthorMetabox',
            'default'      => array(),
            'capabilities' => true,
        ),
    );

Modified code:

<?php

global $user_login;
get_currentuserinfo();
return array(
    'author' => array(
        'label' => __('Author', 'ait-toolkit'),
        'type' => 'select-dynamic',
        'dataFunction' => 'AitItemCpt::fillAuthorMetabox',
        'default' => $current_user->user_login,
        'capabilities' => true,
    )
);
1

Your question is not very clear to me but here's a version of your code which you may try:

<?php
global $current_user;
get_currentuserinfo();
return array(
    'author' => array(
        'label' => __('Author', 'ait-toolkit'),
        'type' => 'select-dynamic',
        'dataFunction' => 'AitItemCpt::fillAuthorMetabox',
        'default' => $current_user->ID, // or try changing it to $current_user->user_login if it doesn't work
        'capabilities' => true,
    )
);
  • Hi, thank you for answer. I tried, but its the same. ibb.co/hrGUGF ibb.co/fXZGwF – Thomas.D Apr 6 '17 at 18:09
  • not replaced to logged user, need to select it manually with dropdown menu (with users) – Thomas.D Apr 6 '17 at 18:11

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.