PHP echo function in BuddyPress to Hyperlink to Member Profile Pages - wordpress

When I first setup BuddyPress on my site, root profiles were enabled. Basically, if a registered user wanted to edit the account settings of their profile, the URL where they could do that would be: "domain.com/username". However, if you typed in "domain.com/members/username" in your browser, you would get the exact same page.
I decided I did not want root profiles enabled because I preferred the URL to be: "domain.com/members/username", so based on this guide (http://codex.buddypress.org/extending-buddypress/changing-internal-configuration-settings), I edited the code in functions.php to be like this:
define ( 'BP_ENABLE_ROOT_PROFILES', false );
However, in header.php, where my navigation is located, the PHP function is still linking to the root profile that I wanted disabled. This is what it looks like:
Profile
I am trying to figure out how I can change the function so that it links to: "domain.com/members/username" instead of "domain.com/username".

Please remove the define ( 'BP_ENABLE_ROOT_PROFILES', false ); in your function.php file.
Because the Buddypress default provide domain.com/members/username.
And also please check the wp-config.php file if above code is there just remove it
Please try this

Related

How to create custom route to a page in WordPress

I want to set a new Route in WordPress that will be redirected to the desired path by entering a specific pattern.
for example:
When I enter any url like below:
http://mywebsite.com/audio/Everything
http://mywebsite.com/audio/**********
http://mywebsite.com/audio/0123456789
These routes and similar ones redirects to sound.php
http://mywebsite.com/wp-content/sounds/sound.php
You can use add_rewrite_rule function, Here is official WP reference - https://developer.wordpress.org/reference/functions/add_rewrite_rule/
As per your example above, You can do like below,
add_action('init', 'custom_rewrite_rule', 10, 0);
function custom_rewrite_rule() {
add_rewrite_rule('^audio/([^/]*)/?','wp-content/sounds/sound.php','top');
}
Try above code as per your requirement and add into your theme's
function.php OR plugin file.
After code added, You must Go to Settings > Permalinks page on your site admin panel and do click on Save Changes button.

How can I display Product Images to Logged In Users only, with Logged Out Users seeing an alternative image?

I would like to modify my WordPress/WooCommerce website, so that my Product Images have the following conditions:
Logged in site visitors:
I would like logged in visitors, to be able to see all of the WooCommerce Product Images.
Logged out site visitors:
I would like logged out visitors, to see an alternative image. Therefore, hide the Product Image. This alternative image, will be the same for every Product.
Firstly, you are going to need to create a Child Theme, for your WordPress/WooCommerce website.
Once created, simply insert the following code, into the functions.php file, within your Child Theme:
<?php
// Remove Default WooCommerce Product Images/Placeholders.
remove_action( 'woocommerce_before_single_product_summary', 'woocommerce_show_product_images', 20 );
// Create conditional logic function.
function logged_in_images(){
// If site visitor is Logged in, display Default WooCommerce Product Images/Placeholder.
if ( is_user_logged_in() ) {
echo woocommerce_show_product_images();
}
// If site visitor is not logged in, display the following Image instead.
else {
echo '<img src=http://vaporcenter.be/theme/Wholesale/img/placeholders/default.jpg?1504084579>';
};
}
// We are inserting ('Hooking' into) the above function into where the Default WooCommerce Product Image/Placeholder was, before we removed it.
add_action( 'woocommerce_before_single_product_summary', 'logged_in_images', 20 );
?>
Be sure to replace http://vaporcenter.be/theme/Wholesale/img/placeholders/default.jpg?1504084579 with your desired image.
Don't forget, you can remove the comments (// ...) from the code. They are there, to just help explain what is happening.
I have tested the above code and it does work.
Best of luck!
If you receive an error
Step One: Using an FTP client, such as Filezilla, go into your Root Folder (Where you installed WordPress).
Look for a file entitled wp-config.php and drag this to your computer.
Open the file, using Notepad/Notepad++ and look for the line define('WP_DEBUG', false); and change 'false' to 'true'.
Drag the wp-config.php file back from where you got it from.
Refresh the page you are having an issue. You should then see an error message, which will be helpful in addressing how to resolve any issues.
Once you have resolved your issue, and your website is back in working order, head back into your wp-config.php and change 'true' back to 'false'.

Duplicated permalinks on a wordpress page

First I have www.mywebsite.com/blog/ Which is another wordpress Blog under www.mywebsite.com.
Then I created a page inside www.mywebsite.com which has a url of www.mywebsite.com/blog/.
I want to change the first www.mywebsite.com/blog into www.mywebsite.com/blog2 so It won't confuse me anymore.
After changing the permalinks in the admin panel. I can't access www.mywebsite.com/blog anymore.
Is there any way to access the page of the original www.mywebsite.com/blog2/wp-admin? and view the duplicated page www.mywebsite.com/blog/?
Please comments if my question confuses you.
Thanks.
When moving your site, give the guide to moving wordpress or, in this case better, the guide of changing the wordpress url a glance.
Suppose you changed the URIs where you cannot move the files, but still can access the login page (through a redirection or something) you can recover your installation easily.
wp-login.php can be used to (re-)set the URIs. Find this line:
require( dirname(__FILE__) . '/wp-load.php' );
and insert the following lines below:
//FIXME: do comment/remove these hack lines. (once the database is updated)
update_option('siteurl', 'http://your.domain.name/the/path' );
update_option('home', 'http://your.domain.name/the/path' );
run it (once) and you are done. Test your site to make sure that it works right. If the change involves a new address for your blog, make sure you let people know the new address, and consider adding some redirection instructions in your .htaccess file to guide visitors to the new location. Delete those lines from your wp-login.php.

(wordpress)Plugin Error:You do not have sufficient permissions to access this page

My plugin which adds a menu in admin page has two files.
The code of the main file (special.php) is as follows:
add_action('admin_menu', 'my_add_pages');
function my_add_pages() {
add_menu_page('special', 'special', 'manage_options', __FILE__, 'specialPage');
}
function specialPage() {
....
}
In the function specialPage(), I write a link:
<a href="admin.php?page=special/special_edit.php?do=edit&id=<?php echo $spec->spec_id;?>">Edit<a>
I write this link because i want to go to another file special_edit.php. The file is in the same folder (plugin/special) as special.php.
However when i click the "Edit" link, it reminds me that "You do not have sufficient permissions to access this page".
Where does the problem come from? How can I solve it?
admin.php?page=special/special_edit.php?do=edit&id=...
I think you must replace the second ? with a &
And probably drop the .php extension of the page parameter (just guessing, here, I haven't hacked WordPress much).
[UPDATE] I checked, and it seems that with add_menu_page, you should use an identifier like 'special_edit' in the menu slug, instead of __FILE__. Would look nicer anyway, and will be independent of your file names.
Edit table wp_usermeta and change value of wp_capabilities to:
a:1:{s:13:”administrator”;b:1;}

how to change the link in the wordpress email with newpassword?

how to change the link in the wordpress email with newpassword?
this information we get when we click on forgot password.
username : admin
password : admin
http://www.example.com/wp-login.php
here i want to change this url "http://www.example.com/wp-login.php" and set my own url... how can i do?
some reference code:
if ( !function_exists('is_user_logged_in') ) :function is_user_logged_in() {
$user = wp_get_current_user();
You can hook into the retrieve_password_message filter
function someFunction($message, $key){
}
add_filter('retrieve_password_message', 'someFunction');
You would then have to use the "someFunction" function to parse the $message variable and change the link.
The message variable contains the entire message. So you could simply trim the message based on the number of characters then tack on your new link...
HTH
(Untested)
Using hooks would be my first thought so that you wouldn't have to edit any core files, however I have used the SB Welcome Email Editor plugin a couple times for this exact reason. Their are a couple plugins like this out their and they are fairly light weight and allow full customization of all Wordpress generated emails.
Try using a plugin such as Theme My Login, which does everything for you.
Editing core wordpress files is never a good idea, when updating wordpress, you'll loose all your work.
You can simply follow steps if you want to edit your code file.
Go to your wordpress folder. Look for the following files:
1. /wp-login.php
2. /includes/functions.php
Change the all the codes which contains wp-login.php into your custom URL.
for example: admin.php or client-login.php
Now you can changed your login/signup URL into your custom URL.
Known issue: You can find some database error if you make any mistakes. Just refresh the page and try with the customized Url it will work...
Example site I used here : http://androideveloper.com/admin.php from http://androideveloper.com/wp-login.php
Cheers.

Resources