Wordpress redirect from URL with BuddyPress - php

I am using the plugin BuddyPress on my WordPress site and when the user clicks on their profile they are redirected to the URL "/members/USERNAME/profile/home/". However, I do not want this page to be there and so I would like the profile 'landing' page to be the URL "/members/USERNAME/activity/".
I am not experienced with WordPress or PHP but I attempted to code a redirect for this when the user ends up on the 'home' page which is placed within my BuddyPress members/single/home.php file within my child theme:
$redirect_url_home = get_home_url();
$redirect_url_home_tt = $redirect_url_home;
$username_redirect_tt = wp_get_current_user();
$new_redirect_slug = "'/members/'.$username_redirect_tt->user_login.'/activity/'";
$redirect_url_home_tt. = $new_redirect_slug;
echo($redirect_url_home_tt);
wp_safe_redirect( $redirect_url_home_tt );
This code doesn't work but that was my thinking of how to solve my problem and I'm sure there is an easier/nicer way to do what I would like, maybe even without a coded redirect and within BuddyPress itself? I have tried using their forum/documentation for answers but haven't had a reply or found anything useful.
As I say I have no experience with this sort of stuff so any help would be greatly appreciated! Also, to add, I cannot link the site as it is currently on a localhost.
Thanks!
This question was originally posted on StackExchange here (https://wordpress.stackexchange.com/questions/386414/wordpress-redirect-from-url-with-buddypress) but I have had no reply as of yet and I would really like one so hopefully, this reaches someone that can help!

Related

PHP custom login Page with sessions and wordpress shortcode

I could use some help. I am a beginner with programming php. I am using PHP because my website is done using wordpress. I have a custom login page developed using PHP. I have an employee portal where the user logs in which is sessioned. Now, my issue is i have a wordpress shortcode for "Tabs" within the loggedin page. The tabs contain a bunch of absolute links for employees only. The issue now is when i click on those links and then i logout i am still able to access those links externally or bookmark it and never have to login again. How can i either session the shortcode for "tabs" or then how can i session it such a way that when a user logs out those links automatically would redirect the user to the login page. Basically if you have bookmarked or copy paste the link to the browser you should be redirected to the login page. How can i achieve this?
The shortcode is like so: do_shortcode('[ctv_ultimate_oxi id="521"]'); - This are tabs on the loggedin page. The only issue is the absolute links that open on new page. Those links are accessible when bookmarked or copied and pasted later after the user logs out.
I will really appreciate some help with a sample code.
Thank you in advance

How do you put a user's name or ID in the URL on a specific page [WordPress]

I'm new here and complex things in Wordpress still confuse me as I am learning. I am trying to relay a logged in user's ID or username to the URL when on a specific page (the dashboard page). I have tried many plugins that allow you to change parameters of general page taxonomy and slugs but I didn't get anywhere with that at all. It's probably a simple answer, but I don't know how to even approach it. I did alot of Google searches, but all the results keep referring to Wordpress's %author% tag, which IS NOT what I want because it only generates the person who created the page, instead of the currently logged in user.
If anyone can help me I'd be really appreciative. FYI: I am not super skilled in PHP or much back-end as I am more into Front End designing. So if any answers revolve around that please provide a "kindergarten" explanation/answer for me 🌞
All you need here is wp_get_current_user().
<?php
$current_user = wp_get_current_user();
$username = $current_user->user_login;
$user_ID = $current_user->ID;
echo "Welcome $username, your ID is $user_ID";
?>
About how to edit your "dashboard page", you need first to find the page template file and then edit the code inside it.

Symfony routing to WordPress' index.php

my following question is quiet stupid I think, but I couldn't find anything like this, which would have helped me... o.O
I want to create a route to my WordPress index.php and to wp-admin.
When somebody opens mywebsite.com/wordpress he should get redirected to the wordpress site. If one of the admins opens mywebsite.com/admin he should get to the login view of WordPress.
What do I have to do in routing.yml??
Thank you
Jannes
I think this might be what you're looking for : http://symfony.com/doc/current/cookbook/routing/redirect_in_config.html

Determine the current page in PHP within a wordpress plug-in

This issue has been driving me up a wall.
I've been working on a mobile website for a friend who uses wordpress. I'm attempting to modify a wordpress plugin that "rethemes" each page for mobile users. I want the plugin to do it's normal thing ("retheme" the page) iff the user is on the blog page, otherwise (if the user visits a different page, he will be redirected to a different address (the address of the mobile website).
In order to do this, I have to be able to detect whether I'm on the blog page, or a different page when the functions in the plugin are run.
I tried condtionals like is_home, is_page(id), ect., but none of them work. I also tried parsing the url and attempting to determine the page that way, but I can't.
I'm just getting my feet wet with PHP, so I'm really not sure what to try next.
To restate my question: How can I determine whether I'm on a certain page within a wordpress plugin function?
The plugin, for the record, is "Wordpress PDA & iPhoned" (http://imthi.com/wp-pda/)
Here's the relevant code:
function PDAPlugin() {
if(true) {
header("Location: http://adavidcreation.com/mobile");
exit;
}
...
}
This works, but I want to change the if statement to only be true if it's NOT the blog.
Any help would be greatly appreciated!
Try using this, which should retrieve the page id: $id = get_option('page_for_posts');
If this doesnt work -> https://wordpress.stackexchange.com/

Odd - page shows up blank inside an iframe. Why?

I am trying to set up a web-based control panel for some hosting customers that use WordPress.
As you probably know, the URL for administrating a WordPress site is http://domain.com/wp-admin. For example:
http://minutebookreview.com/wp-admin
(this is just a random blog)
Now, look what happens when I try to load this page inside an iframe using this code:
<iframe width=640 height=480 src="http://minutebookreview.com/wp-admin"></iframe>
You'd think this would work, right?
Well, have a look for yourself:
http://jsfiddle.net/A4MxE/
The page simply shows up blank inside the iframe. The wp-admin login page won't load.
Anyone know why this is happening? It doesn't make any sense to me.
Here is what I saw. It seams wordpress just dosen't like you.

Categories