Jump to content

User with alternate parent multi language problem


joshua
 Share

Recommended Posts

Hello everyone,

I'm working with ProcessWire now for more than two years and I'm verry verry satisfied with it!

Currently I'm working on a project with integrated "Frontend CRM" and more functions for frontend-user-interaction.

The Contacts for the CRM are Users with an alternate parent (as introduced in 2.5.14). Almost everything is working perfect so, but now I have one Problem:

When a new user is created via the Frontend (via the great PW Api) it's parent has an name like "/en/crm/contacts/maxmustermann/"

In this case the new created contact is only visible, if the Editor has "english" as language actived. In other languages (currently only German) the new Contact isn't shown.

Here's the codepart, where the page is created:

$c_template = $templates->get("contact");
$c_parent = $pages->get(1018);
$c_name = $sanitizer->pageName($c_forname) . $sanitizer->PageName($c_lastname);
if ($pages->get("name=$c_name")) {
   $date = date("ymdhis");
   $c_name = $c_name .$date; 
}

$nc = new Page();
$nc->template = $c_template;
$nc->parent = $c_parent;
$nc->name = $c_name;
$nc->language = $user->language;

$nc->contact_forname = $c_forname;
$nc->contact_lastname = $c_lastname;
$nc->contact_company = $c_company;
$nc->contact_website = $c_website;
$nc->contact_email = $c_email;
$nc->contact_phone = $c_phone;
$nc->contact_street = $c_street;
$nc->contact_plz = $c_plz;
$nc->contact_town = $c_town;
$nc->contact_country = $c_country;
$nc->email = $c_email;

$nc->save();

The input values are validated before this part.

I want the contact to be visible in all languages.

How can I solve this problem?

Many thanks in advance!

Greets,
Josh

Link to comment
Share on other sites

Thanks - I'll check this out now!

@SiNNuT: Of course! ProcessWire is so brilliant and the support forum also is. I haven't found the time until now to answer questions by others but also didn't need any help until today. But even now it is (as always with ProcessWire) a simple & great solution.

Edit: It works!

foreach ($languages as $lang) {
	if($lang->isDefault()) continue;
	$nc->set("status{$lang}", 1);
}
Link to comment
Share on other sites

Welcome @J0sh,

I also know someone who has built a lot of sites (some great ones too) with ProcessWire in the last 2 years. He also hasn't had a forum account here. (Now he has one because he currently has buyed a ProCache agency licence, but his post counter is still saying 0)

And I believe that there are many other out there. :)

Link to comment
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
 Share

  • Recently Browsing   0 members

    No registered users viewing this page.

  • Similar Content

    • By Clarity
      Hello everyone!
      I'm new here and I want to set an user avatar to my profile. However, I don't see any option in my personal cabinet that can do it. Could you please tell me if there are there some requirements for user for setting an avatar or I'm missing something?
    • By theoretic
      Hi there! And thanks for Processwire!
      I've got an interesting case concerning access to current user page. It appears that PW somehow limits access to the frontend page of current user.
      I'm speaking about a specific PW configuration. We have two kind of users: 'regular' users with native user template and member users with specific member template and specific members parent page (by the way, it's so cool that PW allows to use custom user templates and custom parent for certain user pages!). So a member with name Joe has a page with member template and url like /members/joe .
      The members template has some access limitations: only member users can see pages with member template. It works like a charm in most situations. For example, user Bill (who has member template and is logged in) can browse a page with url /members/ann which also is a member page with member template.
      And now, meet the glitch! The above-mentioned Bill cannot get to his own page /members/bill ! PW generates 404 page instead.
      I see no reason for this behavior. From my point of view any member should have access to any member page in this situation. What am i doing wrong? Any advice is welcome!
    • By VeiJari
      Hello,
      I'm trying to create a page via api and populate values to it. I can populate everything except user pages to a page reference array.
      Code: 
      $dataUsers = $data->project->users; foreach($dataUsers as $dataUser) { $newProject->projectUsers->add(wire()->pages->find('template=user, id=' . $dataUser->id)); } I'm receiving my data via JSON.
      Is there something I'm missing?
      Thanks for help
    • By neonwired
      I'm hoping someone has seen this before. There doesn't appear to be an issue with the user info.

       

    • By prestoav
      Hi there,
      I have a marketplace site that used the older Fredi module for front end editing so advertisers can create and edit their adverts (in the form of pages). After upgrading to v3.0 of Processwire I'd like to change the editing method for users to the new, core front end editing methods. However, it seems that with this method any editor can edit any page (subject to template restrictions for their user role). Using Fredi I checked the user and created user were equal before displaying edit buttons (clunky but it worked).
      Is there any stock way to restrict front end editing to the creator of the page so that my advertisers can only edit their own ads or should I test for user as before?
      Thanks in advance as always 🙂
×
×
  • Create New...