Menu Magento 2.4 - magento2

I would like to know how to make the menu appear after user login in magento 2.4?
Thanks.

If you want the to customer will see the main menu after successfully logged in then you have to check the customer session before load the navigation section.
<?php
$objectManager = \Magento\Framework\App\ObjectManager::getInstance();
$customerSession = $objectManager->get('Magento\Customer\Model\Session');
if($customerSession->isLoggedIn()) {
echo $this->getChildHtml("navigation.sections");
}
?>

Related

Joomla redirect to specific page if not login

Hello Stackoverflow community,
I have a website based on Joomla 3.0
I am trying to get all non-log-in users (aka guest/visitor) redirected to a specific joomla menu item when they visit my website.
Example :
website.com - is default joomla menu item and website homepage
webiste.com/redirect - is joomla menu and website page where I want guest to be redirect automaticaly
Once log-in, the user is redirected to homepage (website.com).
I see tons of Joomla plugins for redirect AFTER loging, but nothing for before loging.
Any idea, maybe some simple php ?
Thank you very much !
B.
You can try following Code for redirect login page.
$user = JFactory::getUser();
$mainframe = JFactory::getApplication();
if($user->id > 0){
JFactory::getApplication()->redirect('registered user url', $error, 'error' );
}
else{
JFactory::getApplication()->redirect(JURI::base().'index.php?option=com_users&view=login', $error, 'error' ); //redirect to login page
}
It work for me. I hope it will also work for you.
Try this,
$user = JFactory::getUser();
$mainframe = JFactory::getApplication();
if($user->id > 0){
$mainframe->redirect('logged in users url here','message','message type');//last param info,error,success etc
}
else{
$mainframe->redirect('not logged in users url here','message','message type');
}
Hope its helps.

i want to redirect home url from custome login page in magento

i hope this would be very simple question for expert but not for me.
i just want, when my site url is opened then its auto redirect to customer login page
but condition is
when customer is logged and if he clicks on home link then show customer dashboard or customer info.
Can someone help me please provided me any solution,i am using magento 1.7.X
Thanks in Advance
My problem got resolve i made cms page and enter this code
{{block type='core/template' template='page/html/custom_login.phtml'}}
then i made the page and code-
`<?php //Check If Customer Is Logged In Or Not.
if (!Mage::getSingleton("customer/session")->isLoggedIn())
{
$session = Mage::getSingleton("customer/session");
// Store The Current Page Url Where User will be redirected once loggedin
$session->setBeforeAuthUrl(Mage::helper("core/url")->getCurrentUrl());
$customerLoginURL = $this->getBaseUrl() . "customer/account/login";
Mage::app()->getFrontController()->getResponse()>setRedirect($customerLoginURL)- >sendResponse();
}else{
//redirect to login
$customerLoginURL = $this->getBaseUrl() . "customer/account/login";
Mage::app()->getFrontController()->getResponse()->setRedirect($customerLoginURL)->sendResponse();
}
?>`
if any one want to help for this can ask me comment on this

Disable installation of my Facebook App

Is there a way to prevent users from installing my facebook application to their pages, using the link below?
https://www.facebook.com/add.php?api_key=API_KEY&pages
Note: I do not want to disable my application, I just want to disable new installations.
The quickest way to achieve this is to parse the signed_request and compare the page information to a list of page ids you have authorised to use the app.
A very simple implementation would be along the lines of
<?php
$app_secret = 'APPSECRET';
$signed_request = parse_signed_request($_REQUEST['signed_request'], $app_secret);
$page_whitelist = array(PAGEID1, PAGEID2);
if (in_array($signed_request['page']['id'], $page_whitelist)) {
// do stuff
} else {
// output some error message
}
https://gist.github.com/4157347

Social Engine 4 authentication check

I have a website and within it, Social Engine 4.1.4 is just a sub-module. I am using the login system of Social Engine in my website. When a user login and then comes back to the site homepage, I want to show his login status. I mean, that if the user is logged in SE4, then I should greet him with his name. How can I do the same.
My site is not using Zend Framework. Since the session data is stored in the table engine4_core_session, I was thinking of a way to decode the serialized data column in some way by getting the specific user row through the *session_id*. I'm not getting the way to decode the data.
Hi you get de name in socialengine 4 :
in the controller you get this:
public function indexAction()
{
$viewer = Engine_Api::_()->user()->getViewer();
$fields = Engine_Api::_()->fields()->getFieldsValuesByAlias($viewer);
$this->view->name = $fields["first_name"] ." ". $fields["last_name"];
$viewer->getTitle();
}
in your view print this:
<h1><?php echo $this->name; ?></h1>

Facebook - hide content on website till "Like" button clicked

I'm using the wordpress plugin from http://www.sociable.es/facebook-wordpress-plugin-3-0/ on my blog, and I try to figure out, how they hide their download till I click the "Like" button on the post.
I tried:
<fb:fbml version="1.1">
<fb:visible-to-connection>HIDDEN CONTENT</fb:visible-to-connection>
</fb:fbml>
But it didn't work.
Is there a way with the Javascript SDK or any other solution?
Thanks a lot!
I think FBML has been done away with. Found this bit of code:
$request = $_REQUEST["signed_request"];
list($encoded_sig, $load) = explode('.', $request, 2);
$fbData = json_decode(base64_decode(strtr($load, '-_', '+/')), true);
if (!empty($fbData["page"]["liked"]))
{ ?>
You are a fan
<?php } else { ?>
You are not a fan
<?php }
//print_r($_REQUEST);
?>
However, the request variables are not being picked up by my iFrame.
Will update as i figure it out.
NB - would only works for the first time the user likes the page. you'd have to then save the session variable or something.
Here's a ready solution for Wordpress:
Like 2 Unlock for Wordpress