Customizing wordpress navigation header with woocommerce my account - php

I am new to wordpress and I was creating a eCommerce website with woocommerce, then I have an idea to make an custom navigation header where when user is not log in it will show login/register and when login it will show to name of the customer.

There are a few ways you can achieve this.
The easiest option is to use any one of the below plugins. Using these plugins, you can show/hide menu items based on their login status. These plugins also allow you to customize the menu based on User roles as well.
https://wordpress.org/plugins/nav-menu-roles/
https://wordpress.org/plugins/user-menus/
Or you can assign a custom class to the menu item and then you can hide/show them using CSS. "logged-in" class is added to the BODY tag when a user is logged in.

Related

Custom WordPress Plugin - Create A FE Page

I am trying to create a custom plugin that adds a frontend page to the site. I have figured out how to have WordPress create the pages to the DB when the plugin is activated, but that gives the user the ability to delete them so I would like to create them sort of like adding a static page in the theme, but within a plugin.
I have found this article that shows how to use parameters to display a page, but I would rather have it be a specific slug, not a parameter: https://opensynergic.com/make-custom-plugin-front-end-page-in-wordpress/
Any assistance or direction would be amazing!
Thanks!

Custom Wordpress Dashboard for custom user role without a plugin

I am creating a page where a certain type of user upon login should only be able to see my plugin dashboard (or a custom php file), without the WordPress dashboard. Is there a way to do this without an extra plugin?
I am currently using Advanced Access Manager as a way of restricting that given user type of accessing anything else in the dashboard.
I would like to get to a similar result if possible hide every Wordpress-like element or style it to my own design. And I would like to achieve it without using an external plugin or editing the functions.php
You can do custom page template, check if user legged in and then present functionality, then users with subscriber role can access the page because they are singed in. do custom login form and after successful login redirect to that custom page.

How to create admin menu item in wordpress to insert info into theme file

I am trying to integrate a comments policy section on my website. I currently manually entered in by adding some php code on comments.php in my child theme. However, What I would like to accomplish is to create an admin menu item that allows me to change the message in the admin menu any time i need to make changes to the comment policy.
I am guessing there should be a way to have a form on an admin menu page to fill out that will define a param, then in comments.php call that param to echo on the page.
Am I correct? How would I do this?
You can accomplish this with Settings API
You first have to add your option field with add_settings_field
Then you have to register it with register_setting
Then in comments.php you can use get_option to get the value of your field

Wordpress Plugin - Open Pages Inside Admin Panel

I am making a plugin. The plugin has pages that access a database, add, edit and delete records, call stored procedures etc. I have gotten as far as creating the plugin, and adding menus and submenus to the admin panel and having those menu links open in the admin panel. These are pages that handle the adding, deleting and editing of records in the database. Some of these pages have a link that would pass an id for example to another page in order to edit a record.
Those pages that are used in the admin panel of my plugin, that link to other admin pages for my plugin, do not open in the admin panel, they open outside of it. How can I create links in my plugin pages to stay inside of the admin panel of wordpress?
To clarify, I am able to add menu items that load pages in the admin panel. Maybe this screen shot will explain. So how can I open pages inside the admin panel?
In order to display your plugin's administrative UI within the framework of the WordPress dashboard you need to follow quite a few WordPress conventions.
The first is to write code for each administrative panel in a separate function. Each of these functions (one per admin panel in your plugin) must display the panel's HTML elements in a <div> object, allowing WordPress itself to wrap your divs in the dashboard display.
The next is to write a menu-building function for your plugin's dashboard menus, and then register that function with the admin_menu action hook. This menu-building function will contain references to your functions to display administrative panels.
Here is a writeup on the topic. http://codex.wordpress.org/Administration_Menus

Buddypress Xprofile fields & Wordpress custom user meta 2 way sync

I am working a wordpress + buddypress based eCommerce site which has marketpress plugin installed to handle the ecommerce part. The problem i am running into is that both wordpress usermeta and buddypress x-profile fields are not integrated with each other by design.
Within my current setup, users can register using buddypress sign-up and fill in their profile information and edit it as well.
I am trying to get the buddypress profile information to be in sync with Wordpress custom usermeta fields i created so that the buddypress profile information can be used within plugins like marketpress (which relies on wordpress user meta to populate shipping fields for a logged in user). Are there any buddypress & wordpress hooks which can be used here to setup a two way sync between buddypress xprofile and wordpresss user meta fields?
In the Dashboard under 'Settings > BuddyPress > Profile Settings' have you selected "Enable BuddyPress to WordPress profile syncing" ?
I think that it only syncs full names and email addresses.
The available syncing functions are found in
buddypress\bp-xprofile\bp-xprofile-functions.php
function xprofile_sync_wp_profile()
function xprofile_sync_bp_profile()
Perhaps the hooks used there will help you write a function to push BP profile fields to usermeta. But it might be easier to change MarketPress to pull from BP rather than WP.

Categories