I have stuck in serious problem. I want to create a document and upload a word doc from front end after user login. Logged in user is admin. The plugin bp-doc uses WordPress default media uploader to upload file.

The plugin hits .../wp-admin/async-upload.php, but this throws an error An error occurred in the upload. Please try again later, after debuging in console I found 302 Moved Temporarily error and in response there is WordPress login form.

After doing some research I found another error, when I log in from frontend as an admin and goes back to wp-admin it logged me out and asks again to enter username and password.

I unable to go through the errors, anyone can help me what may goes wrong?

I uses the following code to login

$user_data = array();
$user_data['user_login'] = $username;
$user_data['user_password'] = $password;
$user_data['remember'] = $remember; 

$user = wp_signon( $user_data, false );

if ( is_wp_error($user) ) {

$err = "<strong>ERROR!</strong> Invalid username or password";

else {

  wp_set_current_user( $user->ID);

  global $current_user;
  $redirect_to = home_url().'/members/'.$current_user->user_login.'/profile'; 

Live site url: https://www.group50.com/g50consultants


have you tried by setting the second argument of wp_signon() to true or blank? set false will prevent wp_signon() from setting secure cookie which is essential for accessing wp-admin if your using ssl. i have tested and $user = wp_signon( $user_data, true ); works as expected.

| improve this answer | |
  • Sorry. The post is too old and currently I don't have access to that project. Thanks for clarification. – PlanetHackers Jan 12 '17 at 19:10
  • 1
    for some reason i found this question on the top, so i answer it :) – Kudratullah Jan 13 '17 at 18:24

Maybe your switching from https to http after login, you can try this plugin https://wordpress.org/plugins/https-redirection/ to redirect all your site to https, I used it once and also changed my site URL from http://... to https://.... in wodpress settings.

I see that you can simplify your code in these lines:

else {
  $redirect_to = home_url().'/members/'.$user->user_login.'/profile'; 

Beacuse the wp_signon function create all the sessions and fill the current user functions.

| improve this answer | |

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.