Zen Mode

It is currently our zen mode where we get home to rest so that we can come back to work the next day and assist you with your issues.

Official support hours is from 10AM — 7PM Monday to Friday (GMT +8)

Hi Guys,

I have gone through a very basic version of a custom field, autoadduser, which only need a string of userId to add them after registration. Gave 2 or 3 test and it was working. Obviously, this is very limited but wouldn't need a lot to make it to your code standard.

Then, I was trying to go with the same kind of plugin for group. Thus, I went to check the structure of the Custom Group field and saw that all these custom field were all extended from their User parent.
I went to give a try to extend my code and it gives me a : SyntaxError: JSON.parse: unexpected character

I suppose that this is mainly because the way you "extend code" requires a structure that I don't have.

I was planning on extending my code for user and then override the AfterSave function to add user to the group instead.

Can i get some help on that second part. The coder's guide for custom group field doesn't exist and I'm not quite sure how to extend and override or simply start back from scratch, if it's even possible.

10 replies
Jason Rey replied on Thursday, June 26 2014, 01:04 PM
Accepted Answer

1. Table name should be clusterNode

2. If you are writing this function in the groups field, then the second parameter $user is now the $group instead. Hence $group->id is what you are looking for.
  • Jason Rey replied on Wednesday, June 25 2014, 12:50 PM

    Hmm mostly likely all you need to change is that in the config/config.json file, just do:

    "extends": "fields/user/audoadduser"

    This is for the group version of the field.

    And in the autoadduser.php, the class should be

    class SocialFieldsGroupAutoAddUser extends SocialFieldsUserAutoAddUser
  • Alexandre Cayer replied on Wednesday, June 25 2014, 01:46 PM
    Hey Jason,

    Both the config and the php file was what i was using. Here is the files attached.
    I thought the error was coming from my custom user field and not the group one...
  • Alexandre Cayer replied on Wednesday, June 25 2014, 10:17 PM
    Hey Jason,

    I have provided site details in case you don't want to manually install the files.
    Just let me know any changes/updates so I can follow.


  • Alexandre Cayer replied on Thursday, June 26 2014, 06:50 AM

    Tried with a non extended version... same JSON error

    here is the file + its on the server as autoaddusergroup
  • Jason Rey replied on Thursday, June 26 2014, 11:08 AM

    Ah thanks for the access. That will speed things up. I will keep you up to date on any file changes I do.

    Could you describe how/what actions did you perform to reproduce the JSON error?
  • Alexandre Cayer replied on Thursday, June 26 2014, 11:23 AM
    Hey Jason,

    I went to group category and went in custom ield. i manually added the auto user from grid and instead of display onSample, it parse the error.

  • Jason Rey replied on Thursday, June 26 2014, 11:42 AM

    I've made a few changes to the file autoaddusergroup/autoaddusergroup.php. Refer to the attached screenshot for information. :)
  • Alexandre Cayer replied on Thursday, June 26 2014, 12:51 PM
    Hi Jason,

    I think i did try so many combination that I left errors along the way many thanks. I have update the main function:

    	public function onRegisterAfterSave(&$post, &$user)
    // Fill in the id of the target user id that you want.
    $a = explode(",", $this->params->get('default'));

    for( $x=0; $x< count($a);$x++){

    $usertoassign = $a[$x];

    $node = Foundry::table('clusters.nodes');
    $node->cluster_id= ...
    $node->uid = $usertoassign;
    $node->type = "user";
    $node->owner = 1;
    $node->admin =1;
    $node->state = 1;
    $node->created = JFactory::getDate()->toSql();


    (1) is the table name properly or it should be something different like the original name: clusters_nodes ?
    (2) is there a way to access the cluster_id of the group from which this field is on by some kind of global variable? If not, what do you suggest ? Database query to select id from table clusters where creator_uid = user->id ?? What you think... :/

    Thanks again
  • Alexandre Cayer replied on Thursday, June 26 2014, 02:21 PM
    Worked like a charm !
    Super work.
    I will add some feature for the admin and owner feature!

    Thanks Jason
  • Arlex Wong replied on Saturday, June 28 2014, 02:28 PM
    Hello Alexandre Cayer ,

    You're welcome, glad to heard your issues resolved. ;)
    You might want to check these cool stuff :
    http://stackideas.com/easysocial || http://stackideas.com/easyblog || http://stackideas.com/easydiscuss || http://stackideas.com/komento || http://stackideas.com/metaman || http://stackideas.com/joomla-templates

    Demo site : http://stackideas.com/demo
    App Store : http://stackideas.com/apps
    Changelog : http://stackideas.com/changelog
    Support Policy : http://stackideas.com/support
    Feature Request : http://stackideas.com/voices
    Documentation : http://stackideas.com/docs

    You can also contact us via our helpdesk if you would like to require for some customisation or sales question.

    Best Regards
Your time
Stack Ideas time
Support is
It's after office hours

It is currently off working hours and most of us aren't around.

Rest assured that we will get back to your issues as soon as the day starts tomorrow!

Official support hour is:
Monday — Friday. 10:00 am - 7:00 pm
Our timezone:
Kuala Lumpur (GMT +8)