• I’ve this function to login in, but after this i’ve other operations that necessary the login like current_user_can…the login work but after this the other operations are stopped, why ?

    function panel_user_login() {

    $user_login = '';
    $user_pass = '';
    $using_cookie = false;

    if( $_POST ) {
    $user_login = $_POST['log'];
    $user_login = sanitize_user( $user_login );
    $user_pass = $_POST['pwd'];
    $rememberme = $_POST['rememberme'];
    } else {
    $cookie_login = wp_get_cookie_login();
    if ( ! empty($cookie_login) ) {
    $using_cookie = true;
    $user_login = $cookie_login['login'];
    $user_pass = $cookie_login['password'];
    }
    }

    do_action('wp_authenticate', array(&$user_login, &$user_pass));

    if ( $user_login && $user_pass ) {
    $user = new WP_User(0, $user_login);

    if ( wp_login($user_login, $user_pass, $using_cookie) ) {
    if ( !$using_cookie )
    wp_setcookie($user_login, $user_pass, false, '', '', $rememberme);
    do_action('wp_login', $user_login);
    } else {
    if ( $using_cookie )
    $error = __('Your session has expired.');
    }
    }
    }

    panel_user_login();

Viewing 3 replies - 1 through 3 (of 3 total)
  • Thread Starter Marcomail

    (@marcomail)

    i can’t retrive the $user_id after the login function beuase i don’t have the “value” in the input form, what i can do ?

    if (!empty ($_POST['post_author_override'])) {
    $_POST['post_author'] = (int) $_POST['post_author_override'];
    } else
    if (!empty ($_POST['post_author'])) {
    $_POST['post_author'] = (int) $_POST['post_author'];
    } else {
    $_POST['post_author'] = (int) $_POST['user_ID'];
    }

    if (($_POST['post_author'] != $_POST['user_ID']))
    die(__('You cannot post as this user.'));

    if ('publish' == $_POST['post_status'] && !current_user_can('publish_posts'))
    $_POST['post_status'] = 'draft';

    Thread Starter Marcomail

    (@marcomail)

    bump

    Thread Starter Marcomail

    (@marcomail)

    bump

Viewing 3 replies - 1 through 3 (of 3 total)
  • The topic ‘login ok but the function is stopped’ is closed to new replies.