Jump to content

Recommended Posts

Posted

I can't add a new value to a custom PageArray field  for my user.

Quote

$current_user = $users->get(3085);
$current_user->setOutputFormatting(false); 
$current_user->galerias->add('2075') ;
$current_user->save();

 

However, when I create a new user, I CAN add the new PageArray value:

Quote

$new_user = new User();
$new_user->name = 'user_2017';
$new_user->galerias->add('2075');
$new_user->save():

 

I need help. Thank you very much.

 

Posted
$current_user = $users->get(3085);
$current_user->of(false);
$current_user->galerias->add(2075);
$current_user->save();

$existente ???

Posted

@kixe: 

Sorry, I mistyped my "quote code". The $existente variable is actually $current_user.

This is my real code/problem:

Quote

$current_user = $users->get(3085);
$current_user->setOutputFormatting(false);
$current_user->galerias->add(2075) ;
$current_user->save();

It does NOT add the page to my "galerias" pagetype field.

Posted
7 hours ago, beto said:

This is my real code/problem:

Quote

$current_user = $users->get(3085);
$current_user->setOutputFormatting(false);
$current_user->galerias->add(2075) ;
$current_user->save();

It does NOT add the page to my "galerias" pagetype field.

It works for me. Double-check your page IDs, field name, and settings of your Page Reference field (allows multiple pages, 'selectable pages' settings allow the page you are trying to add).

  • 1 year later...
Posted

Can you use something else than page ID here? Like 'name =  pagename' or 'name = $somepage'. What would be the right syntax? Or could you find/get that page ID earlier in the script and put it in a variable?

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
×
×
  • Create New...