25 Posts
yego
10 years ago
8
Topic

Hello,

There is a "site form" for registering new users. It is the same form that is used for the users can modify their username, pasword, email, etc.

Here is the problem, as the form is the same for new users and for already registered users. The redirection and the after saving message is the same, but it should be different, not the same. Otherwise the result, in terms of a friendly user interface, is actually quite bad and ugly. Wich is a pitty because I think sebold is an amazing extension.

Is there any way for doing this "conditional redirection/messaging"?


As alwayys, Thanks in advance!

Diego.

Get a VIP membership
116 Posts
nycxav
10 years ago
0
Level 1
Hi Diego,

Did you find a solution for this problem?
I have a requirement to redirect to a an URL with parameters from the form so I figured you might have found a solution.

Thanks.
Xav.
11 Posts
Joris
10 years ago
0
Level 1
Hello Diego and Xavi,

You can use the onUserAfterSave event of joomla.

Have a look at the user plugins in the /plugins/user directory there you will find for example the /joomla/joomla.php that will serve you as an example of the implementation of the onUserAfterSave event.

Then make your own user plugin for the onUserAfterSaveEvent, below is an example:

Hope this helps, Joris from Pampaneira
defined('_JEXEC') or die;

class PlgUserBootstrapv2 extends JPlugin
{

public function onUserAfterSave($user, $isnew, $success, $msg) {
if ($isnew) {
$jinput = JFactory::getApplication()->input;
$jinput->set('return', base64_encode(JURI::base(). 'newuserredirect'));
}
else {
// Existing user - nothing to do...yet, we use normal redirect.
}
}

}


11 Posts
Joris
10 years ago
0
Level 1
I replied to the topic instead by error, see my new post in this topic with a possible solution...
449 Posts
gebeer
10 years ago
1
Level 1
Hello,

interesting topic.

I have a similar use case where I need conditional messages. One for initial submission of the form. The other one when editing content with the form.

It is a simple order form that sends an Email after submission of the order and then displays a success message to the user.

I have a list with all submitted orders for admins. When they choose an order for editing from the list, the same form will open where they can change order status etc. Now when they save, they get the same message as people who order through the form.

Joris code doesn't apply for my case. And I have no idea how to approach the problem.

Best would be a feature in Seblod where you can set 2 different messages, depending on first submit and editing. I will add this to the tracker.
11 Posts
Joris
10 years ago
0
Level 2
Hi Gebeer,
I asume you are using the email plugin field of seblod to sent the message?

I can see two possible options:
1) drop the use of the seblod email plugin field and write your own onContentAfterSave plugin that send the mail you need to when you need to.
2) copy the email plugin field, rename it to youremail plugin and rewrite the part that needs rewriting so it will sent the messages you need.

Option 1 could be simpler...

Does this help? Joris
693 Posts
rpoy
10 years ago
1
Level 1
Hey Everyone!

I would look at using the User Id field.  If its blank, its a new user.  If it has a value, then its an edit.  Then you could have 2 different Email Fields, one for a New user and one for a Returning user.

You can make a field hidden and disabled, triggered on the User ID field Is Empty...

I think that's the approach that I would take for the email...

Would that work?

Randy

11 Posts
Joris
10 years ago
0
Level 2
Thanks Randy, I will give a try next time, good I didn't know you could do that!
Joris
449 Posts
gebeer
10 years ago
0
Level 1
@Joris
yes, I'm using the Email send field. I think your solution is good if we have more complex tasks after form submit.


@Randy
great idea using the user ID and 2 conditional email send fields. I will give that a try and report back.

Cheers
Gerhard
Get a Book for SEBLOD