Mauro Mello
Forum Replies Created
-
Forum: Plugins
In reply to: [Yoast SEO] Fatal Error on BuddyPress user page after upgradeThanks!! Working fine now! ??
Forum: Plugins
In reply to: [Yoast SEO] Fatal Error on BuddyPress user page after upgradeSame with me. After disabling Yoast SEO it’s working again.
- This reply was modified 5 years, 3 months ago by Mauro Mello.
Hi @intoxstudio
Thanks for your reply. I was able to do a workaround for my site using the code below in my child theme functions.php file.
It’s not a good solution because it is based on the slug of the page that contains the [login-form] shortcode. But was the only way I was able to fix it for my site.
//Removes the filter that was causing the conflict with Restrict User Access add_action( 'after_setup_theme', 'childtheme_remove_filters' ); function childtheme_remove_filters(){ remove_filter( 'login_redirect', 'buddyboss_redirect_previous_page', 10 , 3 ); } //Add new filter that checks if it's on the page where the [login-form] form shortcode is used. It's not a beatiful solution because it is based on the page slug. But was what I was able to do :) add_filter( 'login_redirect', 'child_buddyboss_redirect_previous_page', 100, 3 ); function child_buddyboss_redirect_previous_page( $redirect_to, $request, $user ) { $aviso_parts = explode( '/', $_SERVER[ "HTTP_REFERER" ]); $aviso_part = $aviso_parts[3]; if ( $aviso_part == 'aviso' ) { if(isset($_GET['redirect_to'])) { $redirect_to = urldecode($_GET['redirect_to']); return $redirect_to; } else { return $redirect_to; } } else { if ( buddyboss_is_bp_active() ) { $bp_pages = bp_get_option( 'bp-pages' ); $activate_page_id = !empty( $bp_pages ) && isset( $bp_pages[ 'activate' ] ) ? $bp_pages[ 'activate' ] : null; if ( (int) $activate_page_id <= 0 ) { return $redirect_to; } $activate_page = get_post( $activate_page_id ); if ( empty( $activate_page ) || empty( $activate_page->post_name ) ) { return $redirect_to; } $activate_page_slug = $activate_page->post_name; if ( strpos( $request, '/' . $activate_page_slug ) !== false ) { $redirect_to = home_url(); } } $request = isset( $_SERVER[ "HTTP_REFERER" ] ) && !empty( $_SERVER[ "HTTP_REFERER" ] ) ? $_SERVER[ "HTTP_REFERER" ] : false; if ( !$request ) { return $redirect_to; } $req_parts = explode( '/', $request ); $req_part = array_pop( $req_parts ); if ( substr( $req_part, 0, 3 ) == 'wp-' ) { return $redirect_to; } $request = str_replace( array( '?loggedout=true', '&loggedout=true' ), '', $request ); return $request; } }
Found my problem… My theme (Boss Theme) has a redirect to previous page function (code below) that redirect the user to previous page. This function is very nice, because if I disable it the users are redirected to the dashboard after login.
Is there a way to keep both functions working together? When the login is on a restricted page use rua plugin redirect. When not use this theme function…
/* * **************************** LOGIN FUNCTIONS ***************************** */ function buddyboss_is_login_page() { return in_array( $GLOBALS[ 'pagenow' ], array( 'wp-login.php', 'wp-register.php' ) ); } add_filter( 'login_redirect', 'buddyboss_redirect_previous_page', 10, 3 ); function buddyboss_redirect_previous_page( $redirect_to, $request, $user ) { if ( buddyboss_is_bp_active() ) { $bp_pages = bp_get_option( 'bp-pages' ); $activate_page_id = !empty( $bp_pages ) && isset( $bp_pages[ 'activate' ] ) ? $bp_pages[ 'activate' ] : null; if ( (int) $activate_page_id <= 0 ) { return $redirect_to; } $activate_page = get_post( $activate_page_id ); if ( empty( $activate_page ) || empty( $activate_page->post_name ) ) { return $redirect_to; } $activate_page_slug = $activate_page->post_name; if ( strpos( $request, '/' . $activate_page_slug ) !== false ) { $redirect_to = home_url(); } } $request = isset( $_SERVER[ "HTTP_REFERER" ] ) && !empty( $_SERVER[ "HTTP_REFERER" ] ) ? $_SERVER[ "HTTP_REFERER" ] : false; if ( !$request ) { return $redirect_to; } $req_parts = explode( '/', $request ); $req_part = array_pop( $req_parts ); if ( substr( $req_part, 0, 3 ) == 'wp-' ) { return $redirect_to; } $request = str_replace( array( '?loggedout=true', '&loggedout=true' ), '', $request ); return $request; }
In my case I’m using the [login-form] shortcode. When the user logs in he is ‘redirected’ to the same page. Now the user is logged but goes back to the same page with the [login-form]. And in the address bar I have the selected page url + ?redirect=[urlEncoded link to protected page]
same with me
+1
Hi @intoxstudio,
I have many others plugins installed but none that adds similar or URL redirection functionality…
Do you know how I could try to find if there is another plugin creating any conflict on this redirection? Any hook, filter, etc I could search for?Thanks
Hi! I’m using redirection using conditional logic. The user is redirected to a page where I advise that he needs to log in to have access, but when the user logs in he is not redirected to the original link.
I’ve also tried using the shortcode [login-form] I didn’t include a redirect link on the shortcode because it should be dynamic (should be redirected to the original page he was trying to access.)It should be possible because the url shows “?redirect_to=http%3A%2F%2Fwww.niteroiense.org.br%2Fatividades%2Fprojeto-montanha-para-todos%2F” at the end…
Link for an example: https://www.niteroiense.org.br/atividades/projeto-montanha-para-todos/
Thanks!
- This reply was modified 8 years ago by Mauro Mello.
Forum: Plugins
In reply to: [Instant Articles for WP] Advanced Settings not showing up after updateSame problem for me.
Below is my full code
function sync_xprofile_to_user_meta_one_way_only(){ $user_id = get_current_user_id(); $bp_telefone = xprofile_get_field_data( "Telefone" ,$user_id); $bp_whatsapp = xprofile_get_field_data( "Whatsapp" ,$user_id); if (!empty($bp_whatsapp)) : $em_telefone = $bp_telefone . ' / ' . $bp_whatsapp; else : $em_telefone = $bp_telefone; endif; update_user_meta( $user_id, 'dbem_phone', $em_telefone); } add_action( 'xprofile_updated_profile', 'sync_xprofile_to_user_meta_one_way_only', 10, 0 ); add_action( 'bp_core_signup_user', 'sync_xprofile_to_user_meta_one_way_only', 10, 0 ); add_action( 'bp_core_activated_user', 'sync_xprofile_to_user_meta_one_way_only', 10, 0 );
I don’t know why, but looks like only the ‘xprofile_updated_profile’ action is working… Try to update the profile and check if the field is updated..
Hi @hugobernard
XPROFILE_PHONE_FIELD_NAME is just a generic name. You should use your field name.
I just checked once looking user profile to check it’s working. But you can improve it writing to log or any other action you like…Let me know if you improve this code…
- This reply was modified 8 years, 5 months ago by Mauro Mello.
- This reply was modified 8 years, 5 months ago by Mauro Mello.
Hi! I was able to make it happen with code below inside child-teme function.php:
function sync_xprofile_to_user_meta_one_way_only(){ $user_id = get_current_user_id(); $em_telefone = xprofile_get_field_data( "XPROFILE_PHONE_FIELD_NAME" ,$user_id); update_user_meta( $user_id, 'dbem_phone', $em_telefone); } add_action( 'xprofile_updated_profile', 'sync_xprofile_to_user_meta_one_way_only', 10, 0 ); add_action( 'bp_core_signup_user', 'sync_xprofile_to_user_meta_one_way_only', 10, 0 ); add_action( 'bp_core_activated_user', 'sync_xprofile_to_user_meta_one_way_only', 10, 0 );
OK. I’m not good at custom coding… ?? But I’m looking for a way to keep fields synched. I’ll post here if find anything.
Thanks @angelo_nwl
Thanks @caimin_nwl!!