admin管理员组文章数量:1130349
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);
do_action('set_current_user');
global $current_user;
get_currentuserinfo();
$redirect_to = home_url().'/members/'.$current_user->user_login.'/profile';
wp_redirect($redirect_to);
exit;
}
Live site url:
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);
do_action('set_current_user');
global $current_user;
get_currentuserinfo();
$redirect_to = home_url().'/members/'.$current_user->user_login.'/profile';
wp_redirect($redirect_to);
exit;
}
Live site url: https://www.group50/g50consultants
Share Improve this question edited Apr 1, 2016 at 11:29 fuxia♦ 107k39 gold badges255 silver badges461 bronze badges asked Apr 1, 2016 at 10:35 Sanjay GoswamiSanjay Goswami 3341 gold badge3 silver badges15 bronze badges2 Answers
Reset to default 2have 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.
Maybe your switching from https to http after login, you can try this plugin https://wordpress/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';
wp_redirect($redirect_to);
exit;
}
Beacuse the wp_signon function create all the sessions and fill the current user functions.
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);
do_action('set_current_user');
global $current_user;
get_currentuserinfo();
$redirect_to = home_url().'/members/'.$current_user->user_login.'/profile';
wp_redirect($redirect_to);
exit;
}
Live site url:
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);
do_action('set_current_user');
global $current_user;
get_currentuserinfo();
$redirect_to = home_url().'/members/'.$current_user->user_login.'/profile';
wp_redirect($redirect_to);
exit;
}
Live site url: https://www.group50/g50consultants
Share Improve this question edited Apr 1, 2016 at 11:29 fuxia♦ 107k39 gold badges255 silver badges461 bronze badges asked Apr 1, 2016 at 10:35 Sanjay GoswamiSanjay Goswami 3341 gold badge3 silver badges15 bronze badges2 Answers
Reset to default 2have 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.
Maybe your switching from https to http after login, you can try this plugin https://wordpress/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';
wp_redirect($redirect_to);
exit;
}
Beacuse the wp_signon function create all the sessions and fill the current user functions.
本文标签: uploadsUser loggedin from front end is logged out automatically accessing wpadmin
版权声明:本文标题:uploads - User logged-in from front end is logged out automatically accessing wp-admin 内容由热心网友自发贡献,该文观点仅代表作者本人, 转载请联系作者并注明出处:https://it.en369.cn/questions/1749172752a2327292.html, 本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌抄袭侵权/违法违规的内容,一经查实,本站将立刻删除。


发表评论