In WordPress there is Biographical Info under Profile. I would like to prevent the user from exceeding a maximum length of 400 characters. Also, the number of hyperlinks he can place in the biographical info should not exceed three. How do I do that? I am very familiar with JQuery, if that helps in this question. I am just a newbie with WordPress.
In WordPress there is Biographical Info under Profile. I would like to prevent the
Share
For the Javascript side, you should attach the necessary events to the
descriptionfield. You can load your script via thewp_enqueue_scripthook, and you probably want to do all this in your handler foradmin_enqueue_scripts, where you check for the passed$hook_name, which in this case is the page name. It isuser-edit.phpwhen an admin edits a user, andprofile.phpwhen the user edits their own information (in which caseIS_PROFILE_PAGEwill also be defined asTRUE).For the PHP side, you need the
pre_user_descriptionfilter. This gives you the current biographical text, and your function can change this and return something else.If, instead of silently changing the description, you want to show an error, you should look into the
user_profile_update_errorshook. There you can validate the given data and return error messages to the user.You probably want to wrap this all up in a plugin, so you can keep the code together and easily enable or disable it. A plugin is just a file in the
/wp-content/plugins/directory, most likely in a subdirectory named after your plugin.